Similar to this question开发者_JS百科, how can I make an existing Git branch track a remote SVN branch?
I often find that I start work in a local branch that I then need to push to an SVN server. Is this possible?
The idea remains to push to an existing SVN branch.
Meaning you need:
- to
git svn rebase
an existing SVN branch (called here 'git-svn-branch
') git branch -b work
# new working branch- work...
git checkout git-svn-branch
andgit svn rebase
(make sure master is up-to-date)git checkout work
andgit rebase git-svn-branch
(replay your work on top of the git-svn branch)git checkout git-svn-branch
andgit merge work
(updategit-svn-branch HEAD
towork HEAD
)git svn dcommit
(push back the git-svn branch to SVN repo, with work commits included in it)
You will find that same process in this SO question.
So, in short, when you are working on a local Git branch, and you want to push it to an SVN branch, you need first to import that SVN branch to a 'git-svn' local branch, and then rebase/merge your local branch on it.
You cannot directly push your local Git branch on an SVN remote one.
精彩评论