Checkout remote branch using git svn

I have checked out a svn repository using git svn. Now I need to checkout one of the branches and track it. Which is the best way to do it?

  • Git on Windows - Cannot clone from UNC path
  • Heroku push rejected, failed to compile Ruby/disabledeploys app
  • Revert to local commit?
  • Setting up a development environment for the web
  • Merge a branch with Git Flow keeping the branch still alive
  • Display current branch name in a console (tcsh)
  • How do I manage git submodule subprojects in Eclipse?
  • Running Git through Cygwin from Windows
  • How to make a script to perform git pull?
  • Git - do amended commits persist?
  • How to keep file sync'd in OpenShift?
  • What are git subtree push assertions?
  • One Solution collect form web for “Checkout remote branch using git svn”

    Standard Subversion layout

    Create a git clone of that includes your Subversion trunk, tags, and branches with

    git svn clone -T trunk -b branches -t tags

    The --stdlayout option is a nice shortcut if your Subversion repository uses the typical structure:

    git svn clone --stdlayout

    Make your git repository ignore everything the subversion repo does:

    git svn show-ignore >> .git/info/exclude

    You should now be able to see all the Subversion branches on the git side:

    git branch -r

    Say the name of the branch in Subversion is waldo. On the git side, you’d run

    git checkout -b waldo-svn remotes/waldo

    The -svn suffix is to avoid warnings of the form

    warning: refname 'waldo' is ambiguous.

    To update the git branch waldo-svn, run

    git checkout waldo-svn
    git svn rebase

    Starting from a trunk-only checkout

    To add a Subversion branch to a trunk-only clone, modify your git repository’s .git/config to contain

    [svn-remote "svn-mybranch"]
            url =
            fetch = :refs/remotes/mybranch

    You’ll need to develop the habit of running

    git svn fetch --fetch-all

    to update all of what git svn thinks are separate remotes. At this point, you can create and track branches as above. For example, to create a git branch that corresponds to mybranch, run

    git checkout -b mybranch-svn remotes/mybranch

    For the branches from which you intend to git svn dcommit, keep their histories linear!

    Further information

    You may also be interested in reading an answer to a related question.

    Git Baby is a git and github fan, let's start git clone.