How to Use Git with SVN

I’ve been using Git for the last couple years and really love it. SVN doesn’t hold a candle to Git in my opinion. Unfortunately though, not everyone uses Git.

Thankfully, Git provides the git-svn bridge so you can use Git with an SVN repo. It’s a bit different than your typical Git usage but not difficult.

To start off, you’ll want to clone the SVN repo to your computer.

git svn clone -s http://path/to/svn/repo

Notice the -s flag. If you have have the standard SVN layout of trunk, tags, and branches this will make Git aware of that. Otherwise, if you clone without the -s flag you’ll find all of trunk, tags, and branches folders checked out to your filesystem.

After this you can work, branch, commit as you typically would if you were just using Git. When you are ready to pull down the latest changes from SVN simply do the following:

git svn fetch
git svn rebase

The only thing left to do is push your changes to SVN. To do this you use the dcommit command.

git svn dcommit

That’s it. dcommit will push up all your changes. There’s more that you can do with the git-svn bridge but this is just the simple workflow that I use. Check out the docs for more information.