Option to checkout Windows-style and commit Windows-style line endings?

919 views
Skip to first unread message

davehe...@gmail.com

unread,
Apr 20, 2015, 4:56:36 PM4/20/15
to msy...@googlegroups.com
We're all working on Windows computers (including servers), and someone committed the project with Unix-style line endings because they used the default Git for Windows install option "Checkout Windows-style, commit Unix-style line endings", but the problem is some files that may be committed (like .bat files) may not run right on Windows with Unix-style line endings (we're not sure yet).

Is there an option for selecting Windows-style commit settings as well? Or is there a place for me to suggest?

Johannes Schindelin

unread,
Apr 21, 2015, 3:20:34 AM4/21/15
to davehe...@gmail.com, msy...@googlegroups.com
Hi Dave,
If you want to enforce committing Windows-style line endings, that is
not possible.

You can force 'Checkout as-is, commit as-is' in which case Windows-style
line endings are preserved when committing.

However. This would not solve your troubles because you apparently have
mixed line endings in the *repository* already. Our proposed solution
(which apparently was ineffective for your use case, probably because
part of your team chose not to use our solution) is to enforce
Windows-style endings *in the working directory only*, and enforce
Unix-style line endings *in the repository*. This would have addressed
your concern about .bat files, too, BTW, because the .bat files need
Windows-style line endings only in the working directory, not in the
repository, because they never run directly from the repository.

Ciao,
Johannes

Torsten Bögershausen

unread,
Apr 21, 2015, 3:38:02 PM4/21/15
to davehe...@gmail.com, msy...@googlegroups.com
On 2015-04-20 21.43, davehe...@gmail.com wrote:
> We're all working on Windows computers (including servers), and someone committed the project with Unix-style line endings because they used the default Git for Windows install option "Checkout Windows-style, commit Unix-style line endings", but the problem is some files that may be committed (like .bat files) may not run right on Windows with Unix-style line endings (we're not sure yet).
>
> Is there an option for selecting Windows-style commit settings as well? Or is there a place for me to suggest?

It may be a misunderstanding from my side, but in order to find out what's going on,
could you do some tests (in a command window), and post the results?

What does this give:
git config -l | grep core

And what does
git --version
say ?

What does
ls-files -s
say ?

If you find your .bat file in the list,
could you run

git cat-file -p 2cbc915c7b1153fb | od -c
(Where 2cbc915c7b1153fb must be replaced by the sha1 of your bat file)

sky...@gmail.com

unread,
Apr 24, 2015, 1:55:20 PM4/24/15
to msy...@googlegroups.com, davehe...@gmail.com
On Monday, April 20, 2015 at 1:56:36 PM UTC-7, davehe...@gmail.com wrote:
We're all working on Windows computers (including servers), and someone committed the project with Unix-style line endings because they used the default Git for Windows install option "Checkout Windows-style, commit Unix-style line endings", but the problem is some files that may be committed (like .bat files) may not run right on Windows with Unix-style line endings (we're not sure yet).

Is there an option for selecting Windows-style commit settings as well? Or is there a place for me to suggest?

You can use .gitattributes to instruct Git to customize the end-of-line style for different file extensions.

For instance, add this .gitattributes to your repository root to have CRLF endings for .bat files and LF for .sh files.
*.sh eol=lf
*.bat eol=crlf

 
Reply all
Reply to author
Forward
0 new messages