This is a small guide I wrote for my own convenience when I recently was converting an SVN repository to a Git repository. I’ve published it here so that I can easily look up the things I need to remember..
I’ve found most of these examples in the excellent official git-svn documentation.
Cloning the SVN repository
git svn clone <repo-url>
Adding another remote
git remote add <remote-name> <remote-url>
Fetching and rebasing changes from SVN
git svn fetch && git svn rebase
Note that the git-svn documentation has a section discussing rebase vs pull/merge:
Prefer to use git svn rebase or git rebase, rather than git pull or git merge to synchronize unintegrated commits with a git svn branch. Doing so will keep the history of unintegrated commits linear with respect to the upstream SVN repository and allow the use of the preferred git svn dcommit subcommand to push unintegrated commits back into SVN.
Doing work and pushing to SVN
git add <file> git commit -m "<commit message>" git svn dcommit # This will push your changes to the SVN repository
Pushing to other remotes
git push <remote-name>
See what will be pushed to SVN
git diff git-svn HEAD # Assuming your remote SVN branch is called git-svn
git svn dcommit --dry-run
You can verify that this post was written by me by pasting the signature into keybase.io/verify.