Git on windows: Can't switch branch after renaming a file (only changed case)

假如想象 提交于 2019-12-01 03:19:51

A simple (but inelegant) way to overcome this problem without having to change the config setting is to delete the file and to check it out again. In my case this allowed my changes branches as normal again.

Edit: As Avivr has pointed out, my proposed workaround doesn't solve the problem permanently. I will still not delete this answer because it may help as a temporary hot-fix in some cases.

VonC

As mentioned in "Unresolvable Git error: The following untracked working tree files would be overwritten by checkout", setting core.ignorecase to true is a valid way to allow the checkout to proceed.

But I would prefer, as in "GIT: The following untracked working tree files would be overwritten by checkout", to:

  • git add what I just modified (in your case, git mv might have already added the renamed file to the index)
  • git stash, saving the index
  • git checkout -b anotherBranch: this should work since the index is clean
  • git stash pop, if you want to restore the case change on that new index.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!