问题描述
我有一个使用 git svn clone
创建的本地git仓库。我创建了一个本地分支,进行了一些更改,切换回主, git svn rebase
,如果它很好,我将分支合并回主。然后树看起来像这样:
有时,后来当我 这是为什么?我可以阻止它吗?是否有一种简单的方法可以说明分支已合并,或者我应该在完成后删除分支,因此我不会忘记什么已合并或尚未合并? git-svn手册页建议您不要使用合并。这是一个副作用。既然你是分支分支(git svn rebase有点像git pull --rebase),它会有效地重写历史。它可能会抛弃Subversion中已经上游的任何本地提交,例如合并,并且只保留那些真正存在于svn存储库中的提交。由于本地分支的简单合并提交在SVN中没有任何等效,因此您只提交真实更改,所以这些是您在新的基础分支中看到的唯一更改。 git svn rebase $ c $并且得到一些远程更改,这就失去了将a_branch合并到mainline中的事实,并且树看起来像这样:
理想情况下,你的本地分支只应该快速合并,即不生成合并提交。如果情况并非如此,那么您应该考虑将您的本地分支重新定位到主而不是合并它。这避免了完全创建合并提交。
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会失去本地分支合并提交的历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!