The following untracked working tree files would be overwritten by merge, but I don't care

前端 未结 16 1122
挽巷
挽巷 2020-12-02 03:37

On my branch I had some files in .gitignore

On a different branch those files are not.

I want to merge the different branch into mine, and I don\'t care if t

16条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 04:09

    For those who don't know, git ignores uppercase/lowercase name differences in files and folders. This turns out to be a nightmare when you rename them to the exact same name with a different case.

    I encountered this issue when I renamed a folder from "Petstore" to "petstore" (uppercase to lowercase). I had edited my .git/config file to stop ignoring case, made changes, squashed my commits, and stashed my changes to move to a different branch. I could not apply my stashed changes to this other branch.

    The fix that I found that worked was to temporarily edit my .git/config file to temporarily ignore case again. This caused git stash apply to succeed. Then, I changed ignoreCase back to false. I then added everything except for the new files in the petstore folder which git oddly claimed were deleted, for whatever reason. I committed my changes, then ran git reset --hard HEAD to get rid of those untracked new files. My commit appeared exactly as expected: the files in the folder were renamed.

    I hope that this helps you avoid my same nightmare.

提交回复
热议问题