How to apply a patch in Git which contains filename case changes?

I have created a patch which consists of a file name case change:

git mv -f confvars.sh ConfVars.sh
git commit -am 'test filename case change'
git format-patch -M -1 HEAD

but when I then try and apply that patch, I get an error:

  • Git on windows: Can't switch branch after renaming a file (only changed case)
  • How to prevent git from committing two files with names differing only in case?
  • git mv and only change case of directory
  • git conflict with differently cased directory name
  • git status showing two files modified after rename due to case
  • How do I commit case-sensitive only filename changes in Git?
  • git apply 0001-test-filename-case-change.patch
    > error: ConfVars.sh: already exists in working directory
    

    How can I apply this patch without it throwing an error?

    **EDIT**

    To clarify the above example: when applying the patch the file ConfVars.sh doesn’t exist, the file confvars.sh does exist which I would expect to be renamed, instead it displays the above error.

  • Why does git update-ref accepts non /refs references?
  • Git: cloning repository into new repository
  • How to remove a submodule from the current branch
  • How to tell Git that it's the same directory, just a different name
  • Git authentication over apache_mod_krb
  • git diff algorithm that does not rip functions apart? (language-aware diff)
  • One Solution collect form web for “How to apply a patch in Git which contains filename case changes?”

    This appears to be a bug in git-apply where it cannot handle case-changing renames on case-insensitive filesystems. Unfortunately, this is true even when the patch contains an add and delete of the contents, not just a rename. (So omitting the -M flag to git-format-patch is unhelpful.)

    It seems that you have three options, depending on your desired level of pain:

    1. Apply the patch on a case sensitive filesystem and pull the resultant commit into your repository.
    2. Edit the patch manually, changing the resultant filename to be distinct in your repository (for example TEMPORARY-FILE-CHANGE-ME), then rename the file to what you desire after applying the patch
    3. Report this bug and hope that somebody actually cares enough to fix it before you give up and make these changes to your repository by hand
    Git Baby is a git and github fan, let's start git clone.