Using SVN with Git

Once I learned Git I never wanted to go back to the days of svn. The only problem is that SVN is used almost in every linux shop I worked for. Luckily there is git-svn. With git-svn I can just import an svn repositories and use git to browse, branch, merge etc. My typical workflow: 1) Import the repository into git.

mkdir reponame && cd reponame
git svn init -s https://svn.hostname.com/svn/reponame/
git svn fetch --fetch-all #If this step fails because the repo is huge, just run it again
  1. Get a branch to hack on
git br -a 
git co --track -b branchname remotes/branchname
git br -vv #I like -vv to see which branches are tracked and which are just local branches
  1. Keep up with svn commits:
git svn fetch
git svn rebase 

This fetches revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it.

This works similarly to svn update or git pull except that it preserves linear history with git rebase instead of git merge for ease of dcommitting with git svn.

This accepts all options that git svn fetch and git rebase accept. However, --fetch-all only fetches from the current [svn-remote], and not all [svn-remote] definitions.

Like git rebase; this requires that the working tree be clean and have no uncommitted changes.

  1. Commit changes back to svn
git svn dcommit