We have a project which is used by dev under linux and also by dev under windows. Now someone under linux created two files: file1.cpp and File1.cpp in the same directory. they are identical, now when I checkout the branch under windows, it automatically tells me that File1.cpp and file1.cpp have been modified. How can I get rid of file1.cpp and keep File1.cpp ?
if it can be done from windows it would be best, because this problems only affect dev working under windows, and they do not have all access to a linux machine.
CodePudding user response:
TL;DR
While the OS is case insensitive, git mv
is not and you can use it to fix the situation.
Details
I just reproduced your problem, and you can use the (case sensitive) git mv
command to fix things on Windows.
I created a repo with files foo
and FOO
with different contents on a different machine. When I checked it out on Windows, it told me that FOO
was modified but didn't say anything about foo
. I would expect that in your case as well, only one should be flagged as modified if you did a fresh checkout.
Now, that means that foo
was OK, but FOO
was not. So I moved foo
to a new name:
git mv foo foo-renamed
now git status is telling me deleted: FOO
because the OS removed "both foo and FOO" since there was only one file there. So check it out again:
git checkout FOO
and now git status just says I renamed foo and FOO is fine.
Now the two files are distinct, you can use git mv
again if you need, to get to the real names you want to keep in the end. Commit the results when you're happy with them.
Reference
I got my idea from https://www.hanselman.com/blog/git-is-casesensitive-and-your-filesystem-may-not-be-weird-folder-merging-on-windows although my solution is not quite identical and my write up is my own.