Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration files #11

Merged
43 changes: 43 additions & 0 deletions 3-working-with-git/dealing-with-line-endings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
layout: default
title: Dealing with line endings
---

Git was designed to manage large projects, with programmers distributed along the world and working over different platforms. You are probably aware that [different platforms represents the end of line with different codes](http://en.wikipedia.org/wiki/Newline#Representations), so, in order to avoid issues comparing files, Git supports a configuration to convert automatically Windows to Linux representation on storing data and Linux to Windows representation on getting data.

In general, it is great, but some package managers like nuget, require to keep some files without modifications, so it becomes into a problem worst than the original one.

Our recommendation is to keep line ending by default by this configuration in `gitconfig` file ([see more](gitconfig-file.html):

[core]
autocrlf = false

And allow to convert only certain kind of files by `gitattributes` file ([see more](gitattributes-file.html)):

# These files are text and should be normalized (convert crlf => lf)
*.cs text diff=csharp
*.xaml text
*.csproj text
*.sln text
*.msbuild text
*.md text

To be sure that some files (commonly included in the packages) are not touched we recommend to specify it:

# These files should not be normalized
*.js -text
*.css -text
*.less -text

You can see a `.gitattributes` file example [in our GitHub repository](https://github.com/MakingSense/migration-to-git/tree/gh-pages/3-working-with-git/examples/.gitattributes).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use relative links in here so that this works in forks too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because I want to link the file in GitHub and not in GitHub Pages, what do yuo think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Agreed.



### More information

You can read more about this issue and other ways to deal with it in the follow links:

* [You're just another carriage return line feed in the wall](http://www.hanselman.com/blog/YoureJustAnotherCarriageReturnLineFeedInTheWall.aspx)
* [Hanselman - Mind the End of Your Line](http://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/)
* [Stack Overflow - What's the best CRLF handling strategy with git?](http://stackoverflow.com/questions/170961/whats-the-best-crlf-handling-strategy-with-git)
* [GitHub - Dealing with line endings](https://help.github.com/articles/dealing-with-line-endings)
* [Git, Nuget packages and Windows line-endings](http://pampanotes.tercerplaneta.com/2012/07/git-nuget-packages-and-windows-line.html)
95 changes: 95 additions & 0 deletions 3-working-with-git/examples/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# These files are text and should be normalized (convert crlf => lf)
*.cs text diff=csharp
*.xaml text
*.csproj text
*.sln text
*.tt text
*.ps1 text
*.cmd text
*.msbuild text
*.md text
*.vb text
*.resx text
*.c text diff=cpp
*.cpp text diff=cpp
*.cxx text diff=cpp
*.h text diff=cpp
*.hxx text diff=cpp
*.py text diff=python
*.rb text diff=ruby
*.java text diff=java
*.html text diff=html
*.htm text diff=html
*.scss text
*.sass text
*.lisp text
*.clj text
*.sql text
*.php text
*.lua text
*.m text
*.asm text
*.erl text
*.fs text
*.fsx text
*.hs text

*.csproj text=auto merge=union
*.vbproj text=auto merge=union
*.fsproj text=auto merge=union
*.dbproj text=auto merge=union


# Declare files that will always have CRLF line endings on checkout.
*.sln text=auto eol=crlf merge=union

# Images should be treated as binary
# (binary is a macro for -text -diff)
*.png binary
*.PNG binary
*.jpg binary
*.JPG binary
*.jpeg binary
*.JPEG binary
*.gif binary
*.GIF binary
*.bmp binary
*.BMP binary
*.ico binary
*.ICO binary
*.ppm binary
*.pgm binary
*.pbm binary
*.xpm -text diff -merge

# Vector graphics
*.svg -text diff -merge


*.sdf binary

# CMake files
CMakeLists.txt text
*.cmake text

# Makefiles
Makefile text
makefile text
GNUmakefile text
*.mk text


# diff behavior for common document formats
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
218 changes: 218 additions & 0 deletions 3-working-with-git/examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store

# ==================================================
# Other common languages and tools
# ==================================================

# Jekyll generated site
_site/

# Node
npm-debug.log
node_modules

# Xcode
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout

# Ruby
*.gem
*.rbc
.bundle
.config
coverage
InstalledFiles
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp

# Rails
*.sassc
.sass-cache
capybara-*.html
.rspec
.rvmrc
/vendor/bundle
/log/*
/tmp/*
/db/*.sqlite3
/public/system/*
/coverage/
/spec/tmp/*
**.orig
rerun.txt
pickle-email-*.html
config/initializers/secret_token.rb

# YARD artifacts
.yardoc
_yardoc


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example would be an universal-and-for-all-the-projects or what? What if I want to put my example .gitignore for an Android app?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmm, my idea is to have an universal recommendation. If you have an specific .gitignore file for android I suggest you to include all non-problematic lines in current file. And also you could add a clean link for your .gitignore file for android.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with the "global" recommendation strategy. Different technologies will generate different "crap" that we want to ignore automatically, and we will want developers to be aware of what they add and what they exclude, making a conscious decision.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, but I also want to provide an easy way to start a project. I think that it is better to start a new project with this .gitignore file than start without any .gitignore. Also you can adapt it as you want, or use it to take some lines for a new one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'll add an issue to the repo so that we can discuss, and if most of us agree, we'll close the ticket when somebody implements the solution (whatever the solution is).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

·#15 created for this.

17 changes: 17 additions & 0 deletions 3-working-with-git/gitattributes-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
layout: default
title: .gitattributes File
---

A `gitattributes` file is a simple text file that gives attributes to pathnames. Certain operations by Git can be influenced by assigning particular attributes to a path.

You can find more information about how to edit git configuration in [gitattributes Manual Page](http://git-scm.com/docs/gitattributes).

### Dealing with line endings

In order to help on [dealing with line endings](/migration-to-git/3-working-with-git/dealing-with-line-endings.html) and prepare the repository for our more common kinds of projects, we provided a recommended `.gitattributes` file that you can [see in our GitHub repository](https://github.com/MakingSense/migration-to-git/tree/gh-pages/3-working-with-git/examples/.gitattributes).


---

Some text extracted from <http://git-scm.com/docs/gitattributes> ([CC BY SA 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/))
Loading