Line endings with cygwin and Github for Windows

后端 未结 3 763
闹比i
闹比i 2021-02-15 01:50

I\'m want to be able to work on my git projects using both the Github for Windows application as well as git in the command line using Cygwin (on Windows).

But I keep o

3条回答
  •  广开言路
    2021-02-15 02:45

    Working on both Git Bash and Cygwin in Windows is going to make git confuse. That is:

    • clone/checkout a repo under Git Bash. During checking out, git thinks it's on Windows, so usually it uses CRLF to check out text files.
    • run git in Cygwin, git thinks it's on Linux and that repo had been checked out in Linux(which is actually not, according to the previous step). Therefore, when git sees CRLF in Cygwin, it thinks that LF is modified into CRLF so that git reports a lots files changes.

    One way to fix this is to create .gitattributes file in repo's root and add lines like the following:

    *.txt text eol=lf
    

    It tell git when encounter file with suffix .txt, using LF both when writing into "database(.git)" and checking out into working directory.

    reference here

提交回复
热议问题