Git – How to use git svn?


Please provide tips for effectively using git with svn. What are your "best practices"?

Best Solution

When you create the clone, use --prefix=svn/. It creates nicer branch names.

Also, don't neglect the --trunk, --tags, and --branches arguments when doing clone or init.

Fetching is one of the more time-consuming steps, so set up a cron job to do git svn fetch in the background. This is safe because fetching doesn't affect any of your working branches.

( Background info on git svn fetch: This command is executed first whenever you do git svn rebase, so by doing this step ahead of time, your git svn rebase call will usually be faster. The fetch command downloads SVN commits and sticks them into special branches managed by git-svn. These branches are viewable by doing git branch -r, and if you did the above step, they start with "svn/". )

Make sure you know how to use git reflog. I've had a few occasions where git svn dcommit died (usually because I tried to check in something huge) and my commit seemed to be lost. In every case, the commit was easily found in the reflog.