Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git (MacOS) case sensitive overwrite issues

Tags:

git

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.

like image 731
advait Avatar asked Aug 29 '14 20:08

advait


3 Answers

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:

Linux Share

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.

like image 182
vhs Avatar answered Nov 03 '22 04:11

vhs


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.

like image 21
Stuart Miller Avatar answered Nov 03 '22 04:11

Stuart Miller


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.
like image 33
advait Avatar answered Nov 03 '22 03:11

advait