0

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?

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
AIMIN PAN
  • 1,563
  • 1
  • 9
  • 13
  • Maybe some tool auto-edits these files even after stash? Like auto-change line endings and auto-save in some IDEs – Justinas Jun 13 '18 at 08:49
  • I'm voting to close this question as off-topic because bug reports should be send to the Git mailing list. – Micha Wiedenmann Jun 13 '18 at 09:23
  • See https://stackoverflow.com/q/50335447/1256452 for how to analyze the issue. I suspect in your case it is end of line issues rather than overlapping file names, as it was there. – torek Jun 13 '18 at 14:49

0 Answers0