Why do files in the working directory get the modi

2019-07-19 21:02发布

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?

标签: git branch
3条回答
Root(大扎)
2楼-- · 2019-07-19 21:17

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.

查看更多
爷、活的狠高调
3楼-- · 2019-07-19 21:24

The git reset --hard will remove the modification from the index. Try with this additional argument it should be OK after that.

查看更多
相关推荐>>
4楼-- · 2019-07-19 21:26

If the items are not tracked in either branch, the files will show up in git status as untracked, and will survive across checkouts

查看更多
登录 后发表回答