Home > Software design >  There are some changes opening in the linux of a git repo. But the repo is latest in windows
There are some changes opening in the linux of a git repo. But the repo is latest in windows

Time:02-14

My pc is a dual system with Linux Mint and Windows 11. The git repo always has some changes in Linux.

the result of diff common.props

Every time I need to git stash and git stash drop. I don't know how to descript this situation with google.

Help pls. Thanks.

CodePudding user response:

The problem is that you have different line ending settings between Linux and Windows. What you're seeing in Linux is that your files have carriage returns on the end of them, which is the Windows line ending.

The easiest way to solve this is to add this to .gitattributes:

* text=auto

Then, on an otherwise empty working tree, add that file, run git add --renormalize ., and commit. That will cause the files to be renormalized as having LF line endings in the index.

If you're going to be working across OSes, then you'd also do well to add eol=lf to the end of that line in .gitattributes so that files are always handled with LF endings. You'll also need to configure your tools on Windows to emit LF endings instead of CRLF endings. That will prevent line ending differences in the working tree across systems.

  • Related