More tips on how to use Git with a Subversion repository to get some of the Git goodness, local branches, stashes and much more, without having to persuade everyone else on your project to migrate to Git
If you don’t already have git installed then see part I (Installation).
Clone you Subversion repository
Make a local clone of your subversion repository to work with.
Warning: Git does not support svn:externals but luckily you vendor everything with piston, don’t you? If not then various people have written up hacks for managing svn:externals none of which are ideal but they will get you started.
Assuming you use a standard Subversion repository layout (with /trunk, /branches etc.) then this is as easy as
git-svn clone http://svn.foo.org/project/trunk
Tweak your local Git repository
There are a couple more things that you should do to the repository before beginning work
Firstly, tell Git about the files that Subversion ignores, using:
git svn show-ignore >> .git/info/exclude
This appears to work for some projects/Subversion installations and not others. If it doesn’t work you’ll need to create .git/info/exclude file in the project and add file patterns to exclude by hand.
Secondly, recreate any empty folders which are required by the project e.g. /log. You need to do this because Git does not track empty directories.
Now you are ready to go.
Get to work
Make your changes
Make changes to the code base in just the same way as you would with Subversion
Commit your changes to your local master branch
Unless you have been working with local branches this is easy as.
git commit -a
Which will commit all your changes to your local Git repository.
If you have added or removed files you will also need to use git add or git rm to ensure all your changes are committed.
Update your local repository from Subversion
git svn rebase
This brings your local Git repository up to date with the central Subversion repository
It works just like git rebase in that it rewinds your local commits, applies the latest changes from subversion, and then replays your local commits over the top. If there are merge issues you will be warned about them here.
Push your local commits back into subversion
git svn dcommit
This applies each of your local commits in turn to the subversion repository.
Repeat (go back to step 1.)
Further reading
Now you’ve got started here are a couple of good resources for when you get stuck
Best of luck.