SVN branching is
a little super painful on the command line. For all those who worked with git a single minute of their lives, it’s really frustrating. Floor Drees wrote a nice svn tutorial for git users. But it doesn’t need to be so complicated. This post provides handy bash aliases (they work on zsh, too) for easier svn branching, merging and reintegrating.
The SVN problems
Who can remember the whole repository URL which is in fact needed twice for creating a new branch?
svn copy \ http://repo.domain.com/svn/project-x/trunk \ http://repo.domain.com/svn/project-x/branches/easter-egg \ -m "Creating private branch for feature easter egg"
I mean, that’s ridiculous long and most of the time there are no tab completion possibilities. The same applies for reintegrating a branch back into the trunk:
svn merge --reintegrate \ http://repo.domain.com/svn/project-x/branches/easter-egg svn ci \ -m "Reintegrating private branch for feature easter egg into trunk"
But why doesn’t svn use the base repository URL as prefix? Nobody knows.
The solution – make SVN less painful
Add the svnaliases from my github repo, save it into your home and add it to your dotfile and there we go:
create a branch:
svnbr "branchname" "commit message"
update a branch from the trunk:
delete a branch:
switch between trunk / branches:
svnsw trunk svnsw branches/$branchname
Reintegrate a branch back into the trunk:
svnre $branchname "commit message"
Getting more productive
With those fancy aliases it’s super easy to use SVN branching. Save a lot of time during branching and reintegrating – go polish your product instead!
Disclaimer: yes, there are git svn-bridges, but not every (industry) project can switch source control systems in short period of time. And please no git vs svn rants – this post is about getting more out of SVN, not exchanging SVN with Git .
About the Author
Gregor is Co-Founder and CTO of Usersnap, a startup which transforms the way customers and users get in touch on the web by providing visual feedback tools. You can try Usersnap right on this blog! And psst – Usersnap offers 15 free trial – no credit card required.