Best practices for cross platform git config?
Solution 1:
Never turn autocrlf
on, it causes nothing but headaches and sorrows.
There's no excuse to use \r\n
on windows, all decent editors (by definition) can handle \n
.
Solution 2:
I have reviewed that kind of config setting (crlf
) extensively in the question:
distributing git configuration with the code.
The conclusion was:
- checkout/checking .gitattributes files
- list all types which explicitly need that kind of conversion.
For instance:
*.java +crlf *.txt +crlf ...
- avoid doing any kind of conversion of type of files which don't need it, because of the various side-effect of such a conversion on merges,
git status
, shell environment andsvn import
(see "distributing git configuration with the code" for links and references). - avoid any
crlf
conversion altogether if you can.
Now, regarding the specific issue of per-platform settings, branch is not always the right tool, especially for non-program related data (i.e; those settings are not related to what you are developing, only to the VCS storing the history of your development)
As stated in the question Git: How to maintain two branches of a project and merge only shared data?:
your life will be vastly simpler if you put the system-dependent code in different directories and deal with the cross-platform dependencies in the build system (Makefiles or whatever you use).
In this case, while branches could be use for system-dependent code, I would recommend directory for support tools system-dependent settings, with a script able to build the appropriate .gitattributes
file to apply the right setting depending on the repo deployment platform.