scphantm
scphantm

Reputation: 4543

git line endings, need the best option

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

Upvotes: 5

Views: 1413

Answers (1)

crater2150
crater2150

Reputation: 899

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.

Upvotes: 9

Related Questions