Tips on Subversion
I recently had to work on multiple issues simultaneously. After resolving the first issue I realized that I had committed the changes to a wrong branch. My challenge was to remove these changes from the code before further damage happens and that too in a quick time. I had few options in mind to resolve the situation; I can either remove all my changes in my next commit or revert back my mistaken commit. The best possible way I felt was to go with my second option i.e. undo my mistaken commit. Here are some tips on subversion to illustrate how I did it.
Undo an unwanted/mistaken commit
svn merge -r : http://example.com/repo
svn merge -c http://example.com/repo
revnum is the revision number of the unwanted/mistaken commit.
A few days back, I was working with one of my friends trying to fix a bug. I was using my friend’s laptop who, incidentally, was working on the same code base. My first challenge was to fix the code, once I did that I was ready to go ahead with committing the changes to the repo. But before I could realize that subversion took his username as author from the .subversion directory, the changes got committed. I fix the issue by using the below command:
Change the author of the commit:
svn ps –revprop svn:author “newauthor” -r http://example.com/repo
I would like to share an interesting command which I think is a cool feature in subversion: Resurrecting deleted items: I realized the importance of this command when I was working with my team on a project. I accidently deleted a file /trunk/secret in revision 10. After a few months, in revision 80, I had a situation to go back to the revision 10 file. I used the below command to resurrect the file:
svn copy -r9 http://example.com/trunk/secret ./secret
How about you? Have you been in a similar situation? What would you have done different? It would be particularly interesting if you can (concisely!) describe a situation that really demands similar behavior.