Git Subversion

Enjoy this cheat sheet at its fullest within Dash, the macOS documentation browser.

Cheat sheet for git-svn, using a git client to connect to a subversion repository. See Git and Subversion.

Creating a Repository

git svn init

Initialize a git-svn repo

Initializes the git-svn repository corresponding to a remote subversion repository with the standard layout.

git svn init <svn-repo-url> --stdlayout --prefix=origin/

Standard layout consists of trunk/, tags/, branches/. If the layout isn't standard, you can instead specify the subfolders :

git svn init <svn-repo-url> --trunk=<folder> --tags=<folder> --branches=<folder> --prefix=origin/

Prefix is optional, but the default for git-svn will soon be origin/.

git svn fetch

Fetch subversion commits

Once you've initialized the repository, you need to populate it with the commits from subversion. If you prefer, you can use git svn clone to do an init and fetch together.

git svn clone

Initialize and fetch together

If you prefer to initialize the repository and fetch all at once, you might prefer:

git svn clone <svn-repo-url> --stdlayout --prefix=origin/

You have roughly the same options as you would for git svn init, but it will be followed up with an implicit fetch.

Using the Repository

git svn rebase

Update your repository

You can't have local changes when you do this, so you'll need to commit or stash first.

git svn dcommit

Push your commits

Push the commits that you've committed to your git repository to the remote subversion repository.


git svn branch

Create branch in subversion

Create a new branch in the remote subversion repository:

command 'git svn branch <branch name>'

If you specify -t or --tag, it'll be a tag instead of a branch, but git svn tag is maybe simpler.

git svn tag

Create tag in subversion

Create a new tag in the remote subversion repository:

git svn tag <tag name>

This may be easier to remember than git svn branch --tag <branchname>.

git branch -r

List remote branches

List all the remote subversion branches that your git repository knows about. This is the same command you'd use in git.

git svn fetch

Fetch new branches

Fetches new branches from subversion that your git repository doesn't know about.

git branch

Create a local branch

If you want to create a local branch matching a remote branch but you don't want to switch to it:

git branch <local branch name> remotes/<prefix>/<remote branch name>

git checkout

Switch to a local branch

Once you've created your local branch, switching to it is done in the same way as within git:

git checkout <local-branch-name>

git checkout -b

Create branch and checkout

If you want to create the branch and switch to it right away, you can combine the two:

git checkout -b <local-branch-name> remotes/<prefix>/<remote-branch-name>


git svn find-rev

Finding git commit for svn revision

Finding the git commit corresponding to a revision number in the remote subversion repository:

git svn find-rev r<change number>

git svn info

Getting subversion info

Getting the subversion repository information like svn info would.

git svn show-ignore

Copy subversion ignores

Extract subversion ignore metadata and put it in your git config directory:

git svn show-ignore >> .git/info/exclude