Git-svn: create & push a new branch/tag?

Phillip B Oldham picture Phillip B Oldham · Mar 22, 2010 · Viewed 23.6k times · Source

After cloning an SVN repository using git-svn with the -s option (git svn clone http://server/repo -s), how does one create a branch or tag and have pushed to the relevant branch/tag directory in the repository when dcommiting?

For instance; if I were to use git to create a foobar branch locally (git checkout -b foobar) how can I have git-svn create the branch on the server (http://server/repo/branches/foobar)?

I'm using Git 1.5.5.6.


Please Note:

The accepted method below does not work with Git 1.5.5.6 as there is no git svn branch method. I'm still looking for a solution to this that doesn't involve resolving to working with svn directly.

Answer

mipadi picture mipadi · Mar 26, 2010

You can read all the nitty-gritty details in this tutorial, but the gist is basically the following:

$ git svn branch -m "Topic branch" my_topic            # Create SVN branch called "my_topic"
$ git checkout --track -b my-topic remotes/my_topic    # Create the Git branch for "my_topic"
# Hack hack hack...
$ git svn dcommit --dry-run    # Make sure you're committing to the right SVN branch
$ git svn dcommit              # Commit changes to "my_topic" branch in SVN