[英]in git-svn, how do I change the svn branch that a git branch is tracking?
My normal git-svn workflow is to do my work on a local branch, then merge to master and git svn dcommit
from there to record my commits onto the svn trunk. 我正常的git-svn工作流程是在本地分支上完成工作,然后合并到master和
git svn dcommit
,以将我的提交记录到svn中继上。
However, in my current local branch ( foo
) I'm realizing that this work is going to be around for a while before I feel comfortable committing it to the trunk, and other developers might be involved in it before then. 但是,在我当前的本地分支(
foo
)中,我意识到这项工作将要进行一段时间,然后再将其提交到主干,并且在此之前可能还会有其他开发人员参与。 I would like to "back it" by a svn branch, so that my work is on the server. 我想通过svn分支“支持”它,以便我的工作在服务器上。
I've created a new svn branch ( svnFoo
) from the current trunk and I basically want to "move" foo
so that when I svn dcommit
from it all of its commits get recorded on svnFoo
instead of trunk
. 我已经从当前主干创建了一个新的svn分支(
svnFoo
),我基本上想“移动” foo
以便当我从它进行svn dcommit
,其所有提交都记录在svnFoo
而不是trunk
。
What is the best way to do this? 做这个的最好方式是什么?
git rebase
is your friend here. git rebase
是您的朋友在这里。 Assuming you created the local foo
branch from the local master
branch, and you've done a recent git svn fetch
so your local Git repository knows about the remote svnFoo
branch, the magic command you want is this: 假设您是从本地
master
分支创建的本地foo
分支,并且最近执行了git svn fetch
以便您的本地Git存储库了解远程svnFoo
分支,那么您想要的魔术命令是:
git rebase --onto remotes/svnFoo $(git merge-base master foo) foo
This will find the commit where you branched foo
from master
, and replay all the commits from there to the head of the foo
branch on top of the svnFoo
branch. 这将找到您从
master
分支foo
的提交,并从那里重播所有提交到svnFoo
分支顶部的foo
分支的头部。 Subsequent git svn dcommit
s will commit onto the Subversion svnFoo
branch rather than the trunk. 随后的
git svn dcommit
将提交到Subversion svnFoo
分支而不是主干。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.