Git: File Rename

I wanted to rename a folder from “Frameworks” to “frameworks“, but git would not let me add the new lowercase name. I guess it treats filenames case insensitive, does it?

A git add frameworks/ -f didn’t help

  • Only allow 'git push heroku master' from the master branch
  • Jenkins Slave Doesn't Use Same Ruby Version As On Local Terminal
  • How and where to install Git for MAC OS X 10.5.8
  • setting up git/github on a mac: error on reading usr/local/etc/gitconfig
  • GitHub for Mac crashes on open because of local repository issue
  • How to resync development projects to github after git uninstalled / re-installed from OS X?
  • Git log --pretty=oneline appears to omit first 2 commits
  • Quick guide to get started using Git + GitX with Xcode projects on the mac?
  • 3 Solutions collect form web for “Git: File Rename”

    You can try:

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

    But the issue of case (on Windows for instance) is described in the msysgit issue 228 (again: this should now — June 2014 — work with git 2.0.1)

    there is always an option to set ignorecase to false in the config file that will force Unix like Git semantics on top of NTFS.
    Git supports this behavior but it is not the default – from NTFS point of view a.txt
    and A.txt are the same thing – so Git tries to preserve that as most users would expect

    As a better 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 as stored on disk.

    This blog post illustrates the same issue on MacOs during a rebase:

    The default on Mac OS X file systems is that they are case-insensitive. FFFFFF.gif is the same as ffffff.gif.

    If you delete the file in question, just from the file system, not from the Git index, mind you, you can merge the branch in question, and have it restore the file as if nothing happened.

    The steps are pretty simple:

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

    Anyhow, remember what git mv stands for:

    mv oldname newname
    git add newname
    git rm oldname
    

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

    If you happen to host on Github, you can use the rename function on their website. Had to change the casing for 5 files and found it worked really well.

    I was having a similar problem and couldn’t get a new folder name (different case) to change on remote repos. I found that the easiest solution was just to move the file out of the repo and commit. Triggering a delete action. Then re-add and when I added, it came in with the proper case.

    Git Baby is a git and github fan, let's start git clone.