Create an SVN branch from an existing Git branch
I have cloned an existing SVN project via git svn clone
with no problem so far, but in the mean time I have created a branch in Git only (开发者_如何学Gonot in SVN) and now i would like to synchronize this branch back to an SVN branch (not the trunk).
I have created the branch a little time ago. Is it possible to get back the information stored on that Git branch into SVN?
You can create a new branch in Subversion using git svn branch
. You might want to look at the example in this answer:
- Git-svn: create & push a new branch/tag?
In particular, a good tip in the linked tutorial is to use the --dry-run
option to svn dcommit
to check that when you run the command for real, it'll be pushing to the right branch.
The Pro Git book has a clearer description of how git svn dcommit
decides which svn branch to update. It sounds to me as if you should:
- Create a new svn branch using
git svn branch new-experiment
- Create a local branch to track
remotes/new-experiment
withgit checkout --track -b new-experiment remotes/new-experiment
Rebase the changes from your old git topic branch (let's suppose it's called
experiment
) ontonew-experiment
:git checkout experiment git branch original-experiment git rebase new-experiment git checkout new-experiment git merge experiment
- Try
git svn dcommit --dry-run
to check that the right subversion branch will be updated - If so, do
git svn dcommit
精彩评论