Git: rename file

I wanted to rename the folder from “ Frameworks ” to “ Frameworks ”, but git will not let me add a new lowercase name. I assume it treats case-insensitive file names, right?

A git add frameworks/ -f didn't help

+51
git case-insensitive macos
Oct 13 '10 at 6:02
source share
3 answers

You can try:

  • "git mv -f foo.txt Foo.txt" (note: this is no longer required with git 2.0.1 )
  • set ignorecase to false in the configuration file.



But the case problem (for example, for Windows) is described in msysgit issue 228 (again: it should now - June 2014 - work with git 2.0.1 )

It is always possible to set ignorecase to false in the configuration file, which will force Unix to be used as git semantics over NTFS.
git supports this behavior, but not by default - from the point of view of NTFS, a.txt and a.txt are one and the same - therefore git tries to keep this as most users would expect

As the best workaround you can

 git mv foo.txt foo.txt.tmp && git mv foo.txt.tmp Foo.txt 

which also changes the case of the file stored on disk.

This blog post illustrates the same issue on macOS during rebase:

By default, they are not case sensitive on Mac OS X file systems. FFFFFF.gif same as FFFFFF.gif .

If you delete the file in question simply from the file system and not from the git index, of course, you can merge the branch in question and restore it as if nothing had happened.

The steps are pretty simple:

 $ rm file/in/question.gif $ git merge trunk 



Anyway, remember what git mv means :

 mv oldname newname git add newname git rm oldname 

therefore, if newname and oldname collide, you need to make them different (even if it is only for a short period of time), therefore git mv foo.txt foo.txt.tmp && git mv foo.txt.tmp Foo.txt

+97
Oct 13 '10 at 6:09
source share

If you encounter a host on Github, you can use the rename function on your website. I had to change the case to 5 files and found that it works very well.

+2
Jul 31 '14 at 16:24
source share

I had a similar problem and I could not get a new folder name (another thing) to change on remote repositories. I found that the easiest solution was to simply move the file from the repo and commit. Launching the delete action. Then re-add, and when I add, it came up with the proper case.

+1
Jan 27 '14 at 19:45
source share



All Articles