I recently moved my project from CVS to Git because it sounds popular. However I’m quite disappointed when I was trying to merge major branches. In simple, there are two major branches, master and quickfix. The master has 4 commits from the branch point; the quickfix has 15 commits so these two branches have loads of different codes. So I decided to merge them to make life easier. Checked out the master branch I typed
ezthumb$ git merge quickfix
Auto-merging eznotify.c
Auto-merging ezthumb.c
Auto-merging ezthumb.h
CONFLICT (content): Merge conflict in ezthumb.h
Auto-merging main.c
Automatic merge failed; fix conflicts and then commit the result.
It only merged one file. Apparently there should be more, because
ezthumb$ git status
# On branch master
# Changes to be committed:
#
# modified: ChangeLog
# modified: Makefile
# modified: ezgui.c
# modified: eznotify.c
# modified: ezthumb.1
# modified: ezthumb.c
# modified: ezthumb.lsm
# new file: ezthumb.pdf
# modified: id_lookup.c
# modified: libsmm/libsmm.h
# modified: libsmm/main.c
# modified: libsmm/smm_chdir.c
# modified: libsmm/smm_codepage.c
# modified: libsmm/smm_cwd_alloc.c
# modified: libsmm/smm_cwd_pop.c
# modified: libsmm/smm_cwd_push.c
# modified: libsmm/smm_filesize.c
# modified: libsmm/smm_fstat.c
# modified: libsmm/smm_init.c
# modified: libsmm/smm_mbstowcs.c
# modified: libsmm/smm_pathtrek.c
# modified: libsmm/smm_pwuid.c
# modified: libsmm/smm_wcstombs.c
# modified: main.c
# modified: version.c
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: ezthumb.h
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# output.map
I modified the ezthumb.h and git commit -a to repository. It became more troublesome. Now Git believe these two branches has been merged successfully so refuse to accept any further merge command. Actually there were still over ten different files at large. It took me two hours to find out how to get rid of the wrong merging. I set up a small project trying to confirm the capablity of Git in multiple file merging. It worked quite fine:
testproj$ git merge quickfix
Auto-merging fixtoken.c
CONFLICT (content): Merge conflict in fixtoken.c
Auto-merging misc.c
CONFLICT (content): Merge conflict in misc.c
Auto-merging rename.c
CONFLICT (content): Merge conflict in rename.c
Automatic merge failed; fix conflicts and then commit the result.
The result was what I looked forward: Git marked out the conflicts in these files so I can merge them manually. It sounds quite buggy to me that Git have different behaviour in two projects. I have googled two nights for this issue, nothing alike. Is there anyone know how to workaround this? Surely I can diff and merge files manually one by one, but will make it senseless for a version control system. My Git is 1.7.4.4 in Fedora 14.
Next time, use
git mergetool. It’s much more friendly for newcomers to git.