I have changed a few files name by de-capitalize the first letter, as in Name.jpg
to name.jpg
. Git does not recognize this changes and I had to de
Mac OSX High Sierra 10.13 fixes this somewhat. Just make a virtual APFS partition for your git projects, by default it has no size limit and takes no space.
Sensitive
git
and ln -s /Volumes/Sensitive/git /Users/johndoe/git
Your drive will be in /Volumes/Sensitive/
How do I commit case-sensitive only filename changes in Git?
I've faced this issue several times on MacOS. Git is case sensitive but Mac is only case preserving.
Someone commit a file: Foobar.java
and after a few days decides to rename it to FooBar.java
. When you pull the latest code it fails with The following untracked working tree files would be overwritten by checkout...
The only reliable way that I've seen that fixes this is:
git rm Foobar.java
git commit -m 'TEMP COMMIT!!'
git rebase --continue
git rebase -i HEAD~2
and drop
the TEMP COMMIT!!
FooBar.java
1) rename file Name.jpg
to name1.jpg
2) commit removed file Name.jpg
3) rename file name1.jpg
to name.jpg
4) ammend added file name.jpg
to previous commit
git add
git commit --amend
When you've done a lot of file renaming and some of it are just a change of casing, it's hard to remember which is which. manually "git moving" the file can be quite some work. So what I would do during my filename change tasks are:
This will fix all the case issues without trying to figure out which files or folders you renamed.
Using SourceTree I was able to do this all from the UI
FILE.ext
to whatever.ext
whatever.ext
to file.ext
It's a bit tedious, but if you only need to do it to a few files it's pretty quick
Git has a configuration setting that tells it whether to be case sensitive or insensitive: core.ignorecase
. To tell Git to be case-senstive, simply set this setting to false
:
git config core.ignorecase false
From the git config documentation:
core.ignorecase
If true, this option enables various workarounds to enable git to work better on filesystems that are not case sensitive, like FAT. For example, if a directory listing finds
makefile
when git expectsMakefile
, git will assume it is really the same file, and continue to remember it asMakefile
.The default is false, except git-clone(1) or git-init(1) will probe and set
core.ignorecase
true if appropriate when the repository is created.
The two most popular operating systems that have case-insensitive file systems that I know of are