简体   繁体   中英

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 (not 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:

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 with git checkout --track -b new-experiment remotes/new-experiment
  • Rebase the changes from your old git topic branch (let's suppose it's called experiment ) onto new-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

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