Why would my local changes in Git be overwritten by checkout in this circumstance?

末鹿安然 提交于 2019-12-05 11:44:58

The reason you get that message is that the underlying file (before your uncommitted modifications) is different between branch A and branch B. If the files were the same, Git would switch branches and keep the same uncommitted modifications after switching to branch A.

One way to bring these changes across is to stash them:

(on branch B)$ git stash
git checkout A
git stash pop

If there are conflicting changes, you may have to resolve the conflict at this point. If there are changes but they don't conflict, then this will succeed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!