Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git line endings, need the best option

Tags:

git

in my repository i have several shell scripts that run in a cygwin console on windows machines. my problem is every time i update those files git automatically converts them to CRLF line endings and i have to manually open them up, convert them to unix, save em, commit them, repeat when updated.

now, if i do

git config --global core.autocrlf false

then git will stop trying to assume what i want by converting the line endings and blindly copy them, correct?

is there a way that i can push this configuration setting to all the users of my repository or does each user have to set this variable themselves

like image 502
scphantm Avatar asked Sep 13 '11 20:09

scphantm


1 Answers

Options that are set with git-config for a single repository are saved inside .git/config, which is not pushed to other users.

But you can get the same result with gitattributes. Attributes can be set in a file named .gitattributes inside the workingtree, so it will be pushed to others. Furthermore they can be set for single files or patterns. Put

*.sh -text

in the .gitattributes file. This will stop all files ending in .sh from being automatically converted.

Alternatively you could write

*.sh eol=lf

to force conversion to unix format.

like image 99
crater2150 Avatar answered Oct 13 '22 12:10

crater2150