git - 为什么工作目录中的文件在 Git 分支之间切换时会获得修改状态?

标签 git branch

我的本​​地 git 存储库中有两个分支:masteranotherbranch 。当我从 master 切换时至anotherbranchgit 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 or git 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/

相关文章:

testing - Mercurial - 提供独立的功能进行测试和上线

python - 如何让我的 Heroku 部署的 Django 支持的项目保持干爽?

git - git filter-branch 的正确并行化

git log 不从 Mac 终端的第一行开始

git - SSL 连接超时

java - 比较 Java 中 Git 分支的基准?

Mercurial:查找存在提交的所有分支

Git - 重新定位到特定标签

git - 撤消 Git 跟踪命令

svn - 删除svn :externals property from a folder