Cheat sheet for git-svn, using a git client to connect to a subversion repository. See Git and Subversion.
Creating a Repository
|
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 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 |
|
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 |
|
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 |
Using the Repository
|
Update your repository You can't have local changes when you do this, so you'll need to commit or stash first. |
|
Push your commits Push the commits that you've committed to your git repository to the remote subversion repository. |
Branches
|
Create branch in subversion Create a new branch in the remote subversion repository: command 'git svn branch <branch name>' If you specify |
|
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 |
|
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. |
|
Fetch new branches Fetches new branches from subversion that your git repository doesn't know about. |
|
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> |
|
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> |
|
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> |
Metadata
|
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> |
|
Getting subversion info Getting the subversion repository information like |
|
Copy subversion ignores Extract subversion ignore metadata and put it in your git config directory: git svn show-ignore >> .git/info/exclude |
Notes
- Created by Geoffrey Wiseman. Contributions welcome.