Over a million developers have joined DZone.

Analog of SVN branch switch for Git

DZone's Guide to

Analog of SVN branch switch for Git

· ·
Free Resource

Working with Git in SVN based organization is possible and make a lot of benefits. Sources checked out once are now at you local repository, so all you do is commits, rebases and dcommits back to SVN. But sometimes you need to be able to switch to another SVN branch. You need something equivalent to "SVN switch" command inside Git environment.

I’m been trying to switch to new branch, but I found no related information about that. I ended up this solution, I would like to share.

  1. Manually add new configuration into ~/.gitconfig, for new SVN location
  2.     [svn-remote "svn25"]
            url = https://svn.server/branches/branch25
            fetch = :refs/remotes/git-svn-25
  3. Fetch changes from svn25
  4.     git svn fetch svn25
  5. Checkout that branch
  6.     git checkout git-svn-25
  7. Create new “master” branch
  8.     git checkout -b master-25
  9. Now, master-25 is your “master” for branch25 SVN branch.

You can merge you previous changes.. and continue to work with master-25 as you worked with usual master.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}