为什么在Git分支之间切换时工作目录中的文件会获得修改后的状态? [英] Why do files in the working directory get the modified status on switching between Git branches?
问题描述
我在本地git存储库中有两个分支: master
和另一个分支
。当我从 master
切换到 anotherbranch
并使用 git checkout anotherbranch
时并运行 git status
我看到已修改的文件。
我使用 git reset撤消了这些修改HEAD
和 git status
不会显示它们。但是,当我切换到master并随后又切换到分支时,我再次看到这些修改后的文件。
您能解释一下发生了什么吗?
您将没有 autocrlf
设置为true ,有机会吗?
因为它可以在结帐时更改文件。 ..
请参见线程 core.autocrlf被认为是半定的:
那时,我不是粉丝
core.autocrlf
支持。
*但是我必须承认,与此同时,我完全不喜欢该功能。
只是尝试执行
git reset --hard
并不是因为它的意图是错误的。
或
git stash
,当有DOS行尾的文件且core.autocrlf不是false时。
绝望。
I have two branches in my local git repository: master
and anotherbranch
. When I switch from master
to anotherbranch
with git checkout anotherbranch
and run git status
I see modified files.
I undo these modifications with git reset HEAD
and then git status
does not display them. However when I switch to master and switch to the branch afterwards I see these modified files again.
Could you please explain what is going on?
You wouldn't have autocrlf
set to true, by any chance?
Because it can change your files on a checkout...
See the thread "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分支之间切换时工作目录中的文件会获得修改后的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!