Tag Archives: subversion

“git svn” Cheatsheet for Git Rebels in an SVN Workplace

This is my own use of git svn. No one in Google seems to have this mix listed out for a Subversion project with a proper trunk/branch/tag setup, so I decided to post what I’ve got.

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