0

我有一个 git-svn 存储库,想将一个分支合并到 master 上。为此,我从分支开始执行了以下步骤:

git commit -m "my commit message"    # commit the changes on the branch
git checkout master                  # change to the branch I want to changes to be merged in
git svn rebase                       # update the repository
git merge --no-ff -m "my commit message" # merge the branch onto master

但是在这个阶段我得到了以下错误:

Auto-merging <file>
CONFLICT (content): Merge conflict in home/httpd/html/data/php/includes/Processes.inc.php
Automatic merge failed; fix conflicts and then commit the result.

然后我去修复一个有问题的文件上的冲突(其他几个文件被很好地合并),并重复最后一个命令,即

git merge --no-ff -m "my commit message" # merge the branch onto master

但出现以下错误:

fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.

好的,然后按照错误消息的提示进行提交,

git commit -m "my commit message"

之后,我查看git log并在输出中看到了两次我给定的提交消息!

最后一次提交不包含任何更改,而所有更改(包括有冲突的文件)都是倒数第二次提交的一部分。

我有三个问题:

  1. 上面究竟发生了什么以创建两个具有相同提交消息的相同提交?
  2. 有没有一种“简单”的方法可以安全地解决这个问题?(我可以做一个git reset HEAD~1来摆脱最后一个空提交吗?)
  3. 如果合并后发生冲突,“标准”程序/命令列表是什么?我应该做一个git mergethen,还是一个git commit或别的什么?

如果有不清楚的地方,请提供评论,以便我可以更新问题并使其更清楚。

4

1 回答 1

1

听起来你做对了。可能您的git log输出显示了分支上的提交和 master 上的合并提交。尝试使用git log --graph --oneline --decoratewhich 应该可以让您查看每个提交所在的分支。

将合并提交与分支提交进行比较应该只显示您为解决合并所做的更改,或者如果合并提交与您的分支提交相同,则不显示。但是比较合并提交git-svn应该显示完整的合并更改。

如果是这种情况,则无需修复 - 无需摆脱旧分支及其提交,尽管git log如果您不使用该--graph选项,它看起来确实令人困惑。

于 2013-05-30T22:09:19.987 回答