Thursday, August 16, 2018

rename - Changing capitalization of filenames in Git



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: destination exists, source=src/collision/b2AABB.js, destination=src/collision/B2AABB.js


As you can see, Git throws a fit over this. I tried renaming using just the plain old mv command as well, but Git doesn't pick up the rename (as a rename or as a new untracked file).




How can I change a file to have a different capitalization of the same name? I am on Mac OS X v10.7.3 (Lion) with Git 1.7.9.1 using Z shell (zsh) 4.3.15.


Answer



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).


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...