I want to switch a git branch, but it said I have 2 files changed, so I did a stash.
$ git stash
Saved working directory and index state WIP on XXX: XXX
So stash is successful. But again checkout branch failed, and it still complain the same 2 files changed.
$ git status
On branch XXX
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: file1.txt
modified: file2.txt
I think Git has a bug here.
The 2 files are text files, originally committed with unix eol, but some user complained when they use samba and open the files with notepad on windows.
So I added a .gitattribute with this content:
*.txt text eol=crlf
It looks ok, but after some period when I switch a branch, problem happens. And there is no way to recover, the only clean way is to remove it completely and clone from origin again.
I am using git 2.16.2, will this problem be fixed in a later version?