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 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.
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:
TEMPORARY-FILE-CHANGE-ME
), then rename the file to what you desire after applying the patchIf you are running Windows 10 (>= 1803, april 2018), you can enable the NTFS case sensitivity by typing the following command (administrator privileges may be required):
fsutil.exe file setCaseSensitiveInfo C:\SampleFolder enable
Now the git apply command should work.
Remarks: Existing subfolders are not affected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With