简体   繁体   中英

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.

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. I would like to "back it" by a svn branch, so that my work is on the server.

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 .

What is the best way to do this?

git rebase is your friend here. 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:

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. Subsequent git svn dcommit s will commit onto the Subversion svnFoo branch rather than the trunk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM