Changing capitalization of filenames in Git

前端 未结 9 1769
孤独总比滥情好
孤独总比滥情好 2020-11-22 14:02

I am trying to rename a file to have different capitalization from what it had before:

git mv src/collision/b2AABB.js src/collision/B2AABB.js
fatal: destinat         


        
9条回答
  •  旧时难觅i
    2020-11-22 14:28

    Starting Git 2.0.1 (June 25th, 2014), a git mv will just work on a case insensitive OS.

    See commit baa37bf by David Turner (dturner-tw).

    mv: allow renaming to fix case on case insensitive filesystems

    "git mv hello.txt Hello.txt" on a case insensitive filesystem always triggers "destination already exists" error, because these two names refer to the same path from the filesystem's point of view and requires the user to give "--force" when correcting the case of the path recorded in the index and in the next commit.

    Detect this case and allow it without requiring "--force".

    git mv hello.txt Hello.txt just works (no --force required anymore).


    The other alternative is:

    git config --global core.ignorecase false
    

    And rename the file directly; git add and commit.

提交回复
热议问题