0

我最近将我的项目从 CVS 转移到了 Git,因为它听起来很受欢迎。但是,当我尝试合并主要分支时,我感到非常失望。简单来说,有两大分支,master和quickfix。master 从分支点有 4 次提交;quickfix 有 15 次提交,所以这两个分支有很多不同的代码。所以我决定合并它们以使生活更轻松。检查了我输入的主分支

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.

它只合并了一个文件。显然应该有更多,因为

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

我将 ezthumb.h 和 git commit -a 修改为存储库。变得更麻烦了。现在 Git 相信这两个分支已经成功合并,所以拒绝接受任何进一步的合并命令。实际上还有十多个不同的文件。我花了两个小时才弄清楚如何摆脱错误的合并。我建立了一个小项目,试图确认 Git 在多个文件合并中的能力。它工作得很好:

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.

结果是我所期待的:Git 标出了这些文件中的冲突,以便我可以手动合并它们。对我来说,Git 在两个项目中的行为不同,这听起来很糟糕。我已经为这个问题搜索了两个晚上,没有什么相似之处。有谁知道如何解决这个问题?当然,我可以一个一个地手动区分和合并文件,但是对于版本控制系统来说这将毫无意义。我的 Git 在 Fedora 14 中是 1.7.4.4。

4

2 回答 2

1

下次,使用git mergetool. git 对新手来说要友好得多。

于 2013-01-30T00:18:04.917 回答
1

I don't see any bug. Without any more details, I can only guess that the merge was successful on all but one of your files. The output states that git was unable to automatically merge ezthumb.h. This is because both branches have changes to the same line (or lines) in that file. You need to open the file and edit it the way you want it to appear after the merge. Then do a regular git add and then a git commit.

于 2013-01-30T00:25:05.597 回答