You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "-text" attribute (and even the "binary" attribute) declaration in .gitattributes fails to completely turn off line ending conversion in Windows. Files with this attribute keep their line endings on commit, but on checkout, they get converted to CRLF. This can cause file hashes to mismatch, breaking signatures.
Additionally, when committing changes to files with this attribute on Windows, Git tries to commit the converted line endings, changing the endings in the repository itself to CRLF.
[ X ] I was not able to find an open or closed issue matching what I'm seeing
Setup
Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.22.0.windows.1
cpu: x86_64
built from commit: d003d728ffa6c0006da875ec6318d3f6b28a4ddb
sizeof-long: 4
sizeof-size_t: 8
Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.18362.145]
What options did you set as part of the installation? Or did you choose the
defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Editor Option: Notepad++
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
Enable Builtin Interactive Add: Disabled
Any other interesting things about your environment that might be related
to the issue you're seeing?
none
Details
Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
(on a Linux machine)
<create a text file containing LF line endings>
sha256sum lf.txt > lf.sha
echo "lf.txt -text" > .gitattributes
git add lf.txt
git add lf.sha
git add .gitattributes
git commit
git push <...>
(on this Windows machine)
git clone <...>
sha256sum -c lf.sha
What did you expect to occur after running these commands?
lf.txt should have been checked out with LF line endings, binary identical to how it was created
What actually happened instead?
A line ending conversion is applied to lf.txt, changing the LF line endings in it to CRLF. This is a problem e.g. if lf.txt is signed, or has its hash stored somewhere.
If I then edit lf.txt and try to commit it, line endings in the committed copy actually get stored as CRLF.
The text was updated successfully, but these errors were encountered:
If there is a conflict, then an MVCE would be an advantage for folks debugging the issue (assuming that the priority order is as you say and that it isn't a documentation conflict)
The "-text" attribute (and even the "binary" attribute) declaration in .gitattributes fails to completely turn off line ending conversion in Windows. Files with this attribute keep their line endings on commit, but on checkout, they get converted to CRLF. This can cause file hashes to mismatch, breaking signatures.
Additionally, when committing changes to files with this attribute on Windows, Git tries to commit the converted line endings, changing the endings in the repository itself to CRLF.
Setup
defaults?
to the issue you're seeing?
none
Details
Git Bash in mintty
Minimal, Complete, and Verifiable example
this will help us understand the issue.
lf.txt should have been checked out with LF line endings, binary identical to how it was created
A line ending conversion is applied to lf.txt, changing the LF line endings in it to CRLF. This is a problem e.g. if lf.txt is signed, or has its hash stored somewhere.
If I then edit lf.txt and try to commit it, line endings in the committed copy actually get stored as CRLF.
The text was updated successfully, but these errors were encountered: