为什么git svn dcommit会失去本地分支合并提交的历史记录? [英] Why does git svn dcommit lose the history of merge commits for local branches?

查看:128
本文介绍了为什么git svn dcommit会失去本地分支合并提交的历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 git svn clone 创建的本地git仓库。我创建了一个本地分支,进行了一些更改,切换回主, git svn rebase ,如果它很好,我将分支合并回主。然后树看起来像这样:



alt text http:/ /img.skitch.com/20090108-cjguu3hcci9x2k17mcftamw8f1.jpg



有时,后来当我 git svn rebase

alt text http://img.skitch.com/20090108-kn3bn1qgi5ijw8ja5ijkd75pa3.jpg



这是为什么?我可以阻止它吗?是否有一种简单的方法可以说明分支已合并,或者我应该在完成后删除分支,因此我不会忘记什么已合并或尚未合并?

解决方案

git-svn手册页建议您不要使用合并。这是一个副作用。既然你是分支分支(git svn rebase有点像git pull --rebase),它会有效地重写历史。它可能会抛弃Subversion中已经上游的任何本地提交,例如合并,并且只保留那些真正存在于svn存储库中的提交。由于本地分支的简单合并提交在SVN中没有任何等效,因此您只提交真实更改,所以这些是您在新的基础分支中看到的唯一更改。



理想情况下,你的本地分支只应该快速合并,即不生成合并提交。如果情况并非如此,那么您应该考虑将您的本地分支重新定位到主而不是合并它。这避免了完全创建合并提交。


I have a local git repository created with git svn clone. I make a local branch, make some changes, switch back to master, git svn rebase and if it's all good, I merge my branch back into master. Then the tree looks something like this:

alt text http://img.skitch.com/20090108-cjguu3hcci9x2k17mcftamw8f1.jpg

Sometimes, later when I git svn rebase again and get some remote changes, it loses the fact that a_branch was merged into the mainline and the tree looks like this:

alt text http://img.skitch.com/20090108-kn3bn1qgi5ijw8ja5ijkd75pa3.jpg

Why is that? Can I stop it? Is there an easy way to tell that a branch was merged, or should I delete my branches when I'm done so I don't forget what has and hasn't been merged?

解决方案

The git-svn man page recommends that you don't use merge. This is one side effect. Since you are rebasing the branch (git svn rebase is a bit like "git pull --rebase") it effectively rewrites history. It may throw away any local commits that are already upstream in subversion, such as the merge, and keep only those commits that really exist in the svn repository. Since a trivial merge commit of a local branch has no equivalent in SVN, you only commit the "real" changes, so these are the only changes seen in your new rebased master branch.

Ideally your local branch should merge fast-forward only, i.e. no merge commit is generated. If this is not the case, then you should consider rebasing your local branch onto master instead of merging it. That avoids creating a merge commit completely.

这篇关于为什么git svn dcommit会失去本地分支合并提交的历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆