I'm working on a team with mixed Linux/MacOS developers. MacOS is case insensitive while Linux is case sensitive. I've got the following issue:
My (MacOS) machine:
$ git checkout master
$ echo hi > MyModule.js
$ git commit -a -m 'Create MyModule.js'
$ git push origin master
$ git checkout -b other-work
... (do work)
Coworker's (Linux) machine
$ git checkout master
$ git pull
$ git mv MyModule.js myModule.js
$ git commit -m 'Rename MyModule.js to myModule.js'
$ git push
My (MacOS) machine
# Currently on branch other-work
$ git fetch
$ git checkout origin/master
error: The following untracked working tree files would be overwritten by checkout:
MyModule.js
# In order to resolve the issue, I have to resort to hackery:
$ rm MyModule.js
$ git checkout origin/master
$ git checkout -- myModule.js # Restore the rm'd file
I'd really like to avoid all of this hackery. I want my MacOS git to be aware of case changes in file names so that so that I can switch between branches freely. I've tried setting the ignorecase
config value to both true and false but this does not help.
As suggested, macOS uses a case-insensitive file system. This is only for the default volume, however. To overcome this issue create another volume on macOS machines which is case-sensitive and store shared code there. Alternatively, standardize within your organization so case-sensitive files are no longer a concern.
To quickly get a volume created on your Mac so you're not blocked while waiting for a standards discussion internally, access Disk Utility and create a new case-sensitive volume like:
That will at least get you moving so your environment will behave like that of your co-workers and the error you were seeing should no longer occur.
They was I get round this is to have a partition formatted as case sensitive.
This is then where all my dev sites are served from.
When switching branches a git checkout --force
does what I want but it's a bit dangerous.
From the git docs:
-f, --force
When switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes.
When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored.
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