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
Considering larsks' answer, you can get it working with a single command with "--force":
git mv --force myfile MyFile
Sometimes you want to change the capitalization of a lot of file names on a case insensitive filesystem (e.g. on OS X or Windows). Doing git mv
commands will tire quickly. To make things a bit easier this is what I do:
git add . -A
to remove all files.git add .
. Git should see that the files are renamed.Now you can make a commit saying you have changed the file name capitalization.
You can open the ".git" directory and then edit the "config" file. Under "[core]" set, set "ignorecase = true" and you are done ;)
To bulk git mv
files to lowercase on macOS:
for f in *; do git mv "$f" "`echo $f | tr "[:upper:]" "[:lower:]"`"; done
It will lowercase all files in a folder.
ignorecase
to false
in git configAs the original post is about "Changing capitalization of filenames in Git":
If you are trying to change capitalisation of a filename in your project, you do not need to force rename it from Git. IMO, I would rather change the capitalisation from my IDE/editor and make sure that I configure Git properly to pick up the renaming.
By default, a Git template is set to ignore case (Git case insensitive). To verify you have the default template, use --get
to retrieve the value for a specified key. Use --local
and --global
to indicate to Git whether to pick up a configuration key-value from your local Git repository configuration or global one. As an example, if you want to lookup your global key core.ignorecase
:
git config --global --get core.ignorecase
If this returns true
, make sure to set it as:
git config --global core.ignorecase false
(Make sure you have proper permissions to change global.) And there you have it; now your Git installation would not ignore capitalisations and treat them as changes.
As a suggestion, if you are working on multi-language projects and you feel not all projects should be treated as case-sensitive by Git, just update the local core.ignorecase
file.
Working example:
git mv ./src/images/poster_video.PNG ./src/images/poster_video.png