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

后端 未结 2 990
栀梦
栀梦 2021-01-11 14:23

I\'m working with git on windows, and I have a file in my repo, lets say \"foo.txt\". Today I wanted to rename this file to \"Foo.txt\" (uppercase). As suggested in this SO

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-11 14:59

    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.

提交回复
热议问题