development
with a file Config.json
.new_development
, where I rename Config.json
to config.json
and commit.development
to see how some things were made in that branch. No errors.new_development
to continue work on new stuff. It shows an error:error: The following untracked working tree files would be overwritten by checkout:
Config.json
Please move or remove them before you switch branches.
Aborting
The file is actually in git.
I have this git config:
[core]
ignorecase = false
How do I make branches switching work when the same files have different case?
How do I make branches switching work when the same files have different case?
Change core.ignoreCase
back to true
.
You are on a case insensitive filesystem; git uses the core.ignoreCase
setting to indicate that. It is configured when you create a repository (either via git init
or by git clone
): git looks at your filesystem to determine whether it's case sensitive or not, and caches that information (in the core.ignoreCase
setting) so that it doesn't have to do this lookup for every operation.
This is not a setting that is meant for you to change.
With core.ignoreCase = false
, on a case insensitive filesystem:
% git ls-tree HEAD
100644 blob 257cc5642cb1a054f08cc83f2d943e56fd3ebe99 foo
% git ls-tree branch
100644 blob bcc9cdfd113753edf279e92afd622b0f3bb05fbc FOO
% git checkout branch
error: The following untracked working tree files would be overwritten by checkout:
FOO
Please move or remove them before you switch branches.
Aborting
This is because I've told git that my filesystem is case sensitive. It looks at the tree that I'm trying to check out, sees that there's a file called FOO
that is not in my current HEAD
tree, and then looks on disk to see if there's an untracked working file with the same name. It stats
the file FOO
(which is really the file foo
, since we're on a case insensitive filesystem) and realizes that you have an untracked file in the working directory.
Except, of course, you don't. You have the file foo
.
If I correct this, setting core.ignoreCase
to reflect the reality of my filesystem, then I can switch branches properly:
% git config core.ignoreCase true
% git checkout branch
Switched to branch 'branch'
% git ls-tree HEAD
100644 blob bcc9cdfd113753edf279e92afd622b0f3bb05fbc FOO
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