简体   繁体   中英

Maintain git local branches when switching svn remote branches

I have been using git-svn working happily along, branching for whatever, rebasing from and dcommitting to trunk and then the powers that be decided that we are going to start working out of a branch instead of trunk. My question is how do I get branches that were spawned from master that was tracking trunk to rebase/merge into the new local branch that is now tracking a new branch?

To attempt to illustrate it, here was my setup prior to the switch (branch/repo names changed to protect the innocent):

Git        ->     svn
master     ->     trunk
 |-feature1
 |-feature2

Now, this is my setup

Git        ->     svn
master     ->     trunk
 |-feature1
 |-feature2
newDev     ->     branches/working

The problem is, I have work in those feature branches i want to get into the svn branch "working". What is the best way to do that?

I couple of months back I implmenented the git svn branch command. You can use that to create new branches in your svn remote, and then work off a local git branch based on that. Committing from those local branches to the right svn branches also works.

If you already have the right local branch around and want to put that into an svn branch that doesn't exist yet, you can also use git svn branch . Use it to create a new remove svn branch based off trunk, pull that into your git repository, and then rebase your local git branch based off your master atop of it.

What you'll end up with is a local git branch containing all your changes sitting atop a commit with a git-svn-id pointing to the branch you just created. When dcommitting from that, your changes will also end up in that svn branch on the remote end.

If in doubt, there's always git svn dcommit -n , which will tell you where exactly git-svn would be committing to.

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