Duplicated file with different case in git origin (bitbucket)

后端 未结 4 571
挽巷
挽巷 2021-01-31 14:47

I am trying to rename files from foobar.php to FooBar.php which is quite a challenge in Git. So far I have found out that I had to set up the git config value of ignorecas

4条回答
  •  耶瑟儿~
    2021-01-31 15:18

    Applied to Directories

    As I was struggling with this issue on a directory level (rather than on a file level), here is the recipe applied to a folder (this was on Windows, git v2.9.2).

    • Bitbucket would be showing two subfolders, say Foobar and FooBar, with different files/folders beneath them.
    • On the client core.ignorecase was set to true and both file trees where merged into one under a common root, say Foobar.
      • Don't set core.ignorecase to false just yet, as it will leave you suddenly with "untracked" files from the other path!
    • git mv Foobar Foobar.tmp - You will get a set of renamed files, but also a set of deleted files and their corresponding untracked ones from the other path.
    • git add . - Stage all the deleted/untracked files.
      • That worked ok for me. Although these appear as deletes/additions, the history of those files is not lost (magically).
    • git commit -m"syncing Foo[Bb]ar into temp. folder" - Commit the temp. folder.
    • git mv Foobar.tmp FooBar - Now rename from temp. to the desired name.
    • git commit -m"moving FooBar into place" - Commit the target name.
    • git push - Now Bitbucket should show a single subdirectory FooBar.
    • git config [--global] core.ignorecase false - Never stumble into that problem again.

提交回复
热议问题