stereochrome

git-svn notes

Some quick notes on using git-svn. I’m not as comfortable with git-svn as I am with git itself.

Checkout from Subversion

$ git svn clone <url> [<localname>]

Time consuming as it clones the whole repo, use -rHEAD for a lightweight checkout of only the current head revision.)

Committing to upstream

$ git svn dcommit

Pushes any pending commits upstream; it’s a push, essentially.

Syncing with the remote repository

$ git svn fetch

NOTE: Doesn’t update working copy.

$ git svn rebase

NOTE: Does update working copy, and linearises history.

Uncommitting the previous commit

$ git reset [--hard|--soft] HEAD^

--hard throws away changes; --soft keeps changes in working copy.

Importing from a git repo into a Subversion repo

$ SVN_REMOTE=https://example.com/repo/PROJECT
$ cd /path/to/git/localrepo
$ svn mkdir --parents $SVN_REMOTE/trunk -m "Init for git import."
$ git svn clone $SVN_REMOTE -s
$ git rebase trunk
$ git svn dcommit

This assumes your git repo is clean. You may need to do a few cycles of the following to clean things up after the initial rebase:

$ git status
$ git add <conflicted-files>
$ git rebase --continue
Created at 14:08 UTC on May 8th, 2012 and last modified at 16:48 UTC on January 26th, 2013