I am writing a project with cpp. when I use git merge other_branch
I concur a wired problem:
On my branch My
, there is a header file Foo.h
in ${PROJECT_ROOT}
directory,on the branch I want to merge other_branch
, there is a header file foo.h
in ${PROJECT_ROOT}
. Foo.h
and foo.h
have different content, when I use the git merge other_branch
on My
branch, git replace Foo.h
with foo.h
. In fact, the Foo.h
disappear, only foo.h
header file exists in ${PROJECT_ROOT}
. To fix the conflict, I rename foo.h
to Foo.h
and change the content, after fixing the problem, I use git add .
and git commit -m "..."
to finish the merge. After doing this, I use git status
to see my workspace condition, I find that Foo.h
is not staged for commit. So I use git add Foo.h
to staged the file but nothing happen, Foo.h
is still not staged for commit, it's wired.
I want to know:
- why git replace
Foo.h
withfoo.h
instead of reporting the conflict? - why doesn't
git add .
work?
PS. When I see the remote repository, I find Foo.h
and foo.h
all exist. and my operating system is MacOS.
My conclusion is: git is case sensitive and MacOS's files are case insensitive, git actually want to keep foo.h
and Foo.h
but OSX regards Foo.h
and foo.h
as one file, so only foo.h
exist, when I rename foo.h
to Foo.h
git still regard Foo.h
as foo.h
, thus when I use git add Foo.h
, git add foo.h
actually, so the Foo.h
in git become a phantom.