Skip to content

Instantly share code, notes, and snippets.

@sammyd
Created May 3, 2012 07:44
Show Gist options
  • Save sammyd/2584090 to your computer and use it in GitHub Desktop.
Save sammyd/2584090 to your computer and use it in GitHub Desktop.
Git SVN
Getting a repository:
git svn clone --tags <tags subfolder> --trunk <trunk subfolder> --branches <branches subfolder>
Updating SVN-tracking remote branches in git:
git svn fetch
Working on trunk:
git checkout master; git svn rebase
Working on a branch for the first time:
git checkout -b local/<branchname> <remote branchname>
Working on a branch:
git checkout local/<branchname>; git svn rebase
After committing, merging, or any other action that changed the local git repository, push to SVN:
git svn dcommit
Making a new branch in SVN:
git checkout master; git svn branch <branchname> -m "Branching for <reason or bug#>"
Making a new tag in SVN:
git checkout <tagged commit>; git svn tag -m "Tagging for <reason or release>"
Deleting a branch in SVN:
svn rm svn://host/path/to/branch; git branch -D local/<branchname>; git branch -D -r <branchname>; rm -rf .git/svn/refs/remotes/<branchname>
Deleting a tag in SVN:
svn rm svn://host/path/to/tag; git branch -D -r tags/<branchname>; rm -rf .git/svn/refs/remotes/tags/<branchname>
Merging a branch (properly):
git checkout <merge-to branch>; git merge --squash <merge-from branch>; git commit; git svn dcommit # --squash is key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment