Skip to content

Creating a SVN branch

Abhik Pramanik edited this page Sep 15, 2011 · 2 revisions

Creating a branch in the SVN repository is pretty simple using git svn.

  1. In the local git repository run git svn branch [-m <message>] <branch name>.

    % git svn branch -m "Test Branch" test-branch 
    Copying https://pl3.projectlocker.com/BranchOut/SvnTestRepo/svn/trunk at r14 to https://pl3.projectlocker.com/BranchOut/SvnTestRepo/svn/branches/test-branch...
    Found possible branch point: https://pl3.projectlocker.com/BranchOut/SvnTestRepo/svn/trunk => https://pl3.projectlocker.com/BranchOut/SvnTestRepo/svn/branches/test-branch, 14
    Found branch parent: (refs/remotes/test-branch) 541cbcdedffaf2176baf8f5776763b60892d6d17
    Following parent with do_switch
    Successfully followed parent
    r15 = aa375997807e036421f7b16f0c2957174b7c56fc (refs/remotes/test-branch)
    
  2. Locally, you're still not working in that branch. You'll need to setup git to track that branch. Unlike in normal Git we need to name the branch differently than the branch in SVN.

    % git checkout -b local/test-branch test-branch
    Switched to a new branch 'local/test-branch'
    
  3. Now we can git dcommit and git svn rebase with the branch in our local branch. To verify this:

    % git svn rebase -n
    Remote Branch: refs/remotes/test-branch
    SVN URL: https://pl3.projectlocker.com/BranchOut/SvnTestRepo/svn/branches/test-branch
    % git svn dcommit -n
    Committing to https://pl3.projectlocker.com/BranchOut/SvnTestRepo/svn/branches/test-branch ...
    

Clone this wiki locally