Skip to content

Commit

Permalink
Merge pull request #11 from andresmoschini/configuration-files
Browse files Browse the repository at this point in the history
Configuration files
  • Loading branch information
andresmoschini committed Mar 7, 2014
2 parents 5c41915 + 9487fb2 commit 8ccd51f
Show file tree
Hide file tree
Showing 7 changed files with 432 additions and 1 deletion.
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).


### 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


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

0 comments on commit 8ccd51f

Please sign in to comment.