The SVN Revert Command That Saved My Bacon

I think it’s happened to all of us. We’ve all done something three weeks ago that we wish we hadn’t. Like that guy you dated, or that burrito you ate. But in this instance I’m talking websites, specifically websites under version control. How many hours have you lost trying to get rid of a change you implemented 5 commits ago, but keep everything after? Even when those changes altered the same files?

I’ve only been using SVN for the past year or so – basically my time at Pop Art. I’ve gotten to use it a lot since I started here. Some days I curse it, some days I love it.

I’m a front-end developer, not a programmer. So while I’m not dealing with intricate lines of C# code, my hairy conflicts involve CSS files or heavily altered JavaScript files. I’ve spent many a day teasing apart lines of CSS after merging a branch to a trunk – to specifically keep a combination of the conflicted files. These are the days I cry.

And then there are those days when you find the magic tool that seems to do exactly what you want. In my case it was: Revert Changes from this Revision.

I had merged a branch that was a drastic change to my JavaScript and CSS files. I had moved from a straight JavaScript solution to one using a jQuery library. The plan was to release it with the other edits that we were making to the same area of the site. I realize now the flaw in my logic; don’t roll two changes into one release – it could bite you. And bite it did. I ran into quite a few snags but luckily I had one distinct commit: One I wanted to roll back, and the rest that occurred later that I wanted to keep.

I poked briefly through Pragmatic Version Control, and didn’t find anything that readily helped me. So I started doing what anyone would do; frantically right clicking and nosing through the Tortoise SVN menu. And there it glistened like a new sun:

  1. Right clicking on the project folder in Tortoise SVN, I chose Show Log.
  2. I selected the revision of my branch join/commit.
  3. I right clicked on this revision and selected Revert Changes From This Revision.

The lines of CSS and JavaScript that were added during the merge were removed, leaving the lines I’d added later; the ones I wanted to keep.

So while I can’t help you with that burrito, or that skeazy guy you dated, I’m hoping you’ll find this helpful!


No Comments on The SVN Revert Command That Saved My Bacon

Comments on this entry are closed.