为什么在Git分支之间切换时工作目录中的文件会获得修改后的状态? [英] Why do files in the working directory get the modified status on switching between Git branches?

查看:897
本文介绍了为什么在Git分支之间切换时工作目录中的文件会获得修改后的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地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 or git stash when there are files with DOS line endings and when core.autocrlf is not false.

And then despair.

这篇关于为什么在Git分支之间切换时工作目录中的文件会获得修改后的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆