我的本地 git 存储库中有两个分支:master
和anotherbranch
。当我从 master
切换时至anotherbranch
与 git checkout anotherbranch
并运行git status
我看到修改过的文件。
我用 git reset HEAD
撤消这些修改然后git status
不显示它们。但是,当我切换到 master 并随后切换到分支时,我再次看到这些修改过的文件。
您能解释一下这是怎么回事吗?
最佳答案
你不会有autocrlf
set to true ,有可能吗?
因为它可以在 checkout 时更改您的文件...
查看主题“core.autocrlf considered half-assed”:
Back then, I was not a fan of the
core.autocrlf
support.
*But I have to admit that in the meantime, I turned into an outright un-fan of the feature. Not because its intent is wrong, but because its implementation is lousy.Just try to
git reset --hard
orgit stash
when there are files with DOS line endings and when core.autocrlf is not false.And then despair.
关于git - 为什么工作目录中的文件在 Git 分支之间切换时会获得修改状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5237783/