Reputation: 5608
I have multiple branches (master, developer and feature/*), and somehow file names were committed with differing cases.
In master and develop branches I have Assets.php and events.php which are correct (they're different vendor libraries hence the case difference). But in a feature branch the file names are currently assets.php and Events.php, the complete opposite casing. When I try to checkout a feature branch I get the following error.
error: The following untracked working tree files would be overwritten by checkout:
assets.php
Events.php
Please move or remove them before you can switch branches.
Aborting
I managed to fix the issue between my master and develop branch through an unscientific series of deleting, committing, re-adding, and committing and I'd rather not repeat that process for my 3 other feature branches.
Since I can't even checkout my feature branch to pull in the changes from master/develop I'm unsure how to work around this without fumbling through a series of removing/adding/committing files on each branch.
What is the best way to fix this?
Upvotes: 0
Views: 124
Reputation: 29092
Since you appear to be on Windows (otherwise you wouldn't have this problem), I would assume that the config setting core.ignorecase
is already enabled, but apparently it's not.
So what I would do:
core.ignorecase
using git config core.ignorecase true
git mv
to fix the case of the filenames(You should also be able to disable core.ignorecase
again and the run git status
to see if there is any mixup.)
If it doesn't work, maybe you need a newer version of Git. I tested this using version "2.8.1.windows.1".
The other solution not relying on core.ignorecase
would be cloning the repo in a new folder, using the -b
argument to specify the branch to check out upon cloning, and fixing things there. Since git mv
won't work for something like a.txt A.txt
if the core.ignorecase
isn't set or isn't supported, you would need to do two moves: git mv a.txt a2.txt
and git mv a2.txt A.txt
.
Upvotes: 1