git 指出分支在变基后未合并 - 为什么?
我正在使用 git-svn 来管理我的错误修复分支,但它告诉我,我有未合并的更改,即使我直接查看 SVN 存储库,我也可以看到它们也已提交。这就像错误修复的变基没有将分支设置为合并。
我在这里做错了什么?
git checkout -b fix_bug_1234
git add .
git commit -m "first change"
git add .
git commit -m "second change"
git rebase -i HEAD~2 // squash the two changes together
git svn rebase // fetch any changes from svn
git checkout master
git rebase fix_bug_1234
git svn dcommit
git branch -d fix_bug_1234
error: The branch 'fix_bug_1234' is not fully merged.
I'm using git-svn to manage my bugfix branches, but it tells me that I have unmerged changes, even though if I review the SVN repo directly, I can see they have been committed too. It's like the rebase of the bug fix is not setting the branch as merged.
What am I doing wrong, here?
git checkout -b fix_bug_1234
git add .
git commit -m "first change"
git add .
git commit -m "second change"
git rebase -i HEAD~2 // squash the two changes together
git svn rebase // fetch any changes from svn
git checkout master
git rebase fix_bug_1234
git svn dcommit
git branch -d fix_bug_1234
error: The branch 'fix_bug_1234' is not fully merged.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
原因是 git rebase 更改了提交对象。因此,虽然实际内容(或差异)与那些重新基准的提交相同,但它们指的是不同的父级,因此是不同的。
这样 gitbranch -d 就无法验证这些提交的更改是否包含在其他一些提交中。然后您需要使用 gitbranch -D(大写的D)来强制删除。
附带说明: git svn dcommit 与 rebasing 具有相同的效果。当 dcommit 将提交推送到 SVN 服务器时,它随后再次从 SVN 服务器获取提交。因此,您最终得到的对象与您推送的对象不同。尽管它们的内容可能相同(除非有冲突),但它们仍然不同(主要原因是 git svn 在提交消息中添加了一行,说明提交所属的 SVN 版本)。
The reason for that is that
git rebase
changes the commit objects. So while the actual content (or diff) is the same with those rebased commits, they are referring to a different parent, and as such are different.That way
git branch -d
cannot verify that the changes of those commits are included in some other commits. You need to usegit branch -D
(uppercaseD
) to force the deletion then.On a side note:
git svn dcommit
has the same effect as rebasing. Asdcommit
pushes the commits to the SVN server, it afterwards gets the commits from the SVN server again. So you end up with different objects than the ones you pushed. Although they may be identical in content (unless you had conflicts), they still differ (main reason is thatgit svn
adds a line to the commit message stating the SVN version the commit belongs to).这就是我做这类事情的方法,而且它有效。用户 poke 的答案解释了为什么 git rebase 没有做你想要的事情。
Here is how I do this sort of thing, and it works. The answer from user poke explains why the git rebase is not doing what you want it to.