Stewart
Stewart

Reputation: 5062

How to revert SVN commit on wrong branch without losing history

I just screwed up and need to figure out how to revert several commits without destroying everything.

I am trying to merge branch1 and branch2 in a temporary branch like so:

1)  svn cp ^/branch1 ^/branch1a  // Create a branch
2)  svn sw ^/branch1a            // Switch to that branch
3)  svn merge ^/branch2 .        // Merge branch2 to branch1a
4)  <do lots of manual work>
5)  svn ci .                     // revision 991,994,995, return to step 4 if needed
6)  svn sw ^/branch1             // When happy, switch back to branch1
7)  svn merge ^/branch1a .       // Merge our happy changes back into branch1
8)  svn ci                       // Commit these changes

I'm still iterating around steps 4-5, but realized that I forgot to do step 2. I need to revert my revisions from branch1, and apply them to branch1a so I can continue work.

I tried to do a revert with svn merge -c991,994,995 ., but my working copy seemed to be unchanged. Also, I need to ensure that I can keep these changes and re-apply them in branch1a. What is a sequence of commands I can use?

Upvotes: 1

Views: 1131

Answers (1)

Stewart
Stewart

Reputation: 5062

I ended up using TortoiseSVN to accomplish this. Instructions are mostly here: https://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-howto-rollback.html

  1. Ensure your working copy is clean and on branch1
  2. Open the log dialogue
  3. Select the revisions you don't like (shift-click for range, ctrl-click of individual revs)
  4. Right click and select "Revert changes from these revisions". This will revert your working copy.
  5. svn ci . to commit the changes to the repo (this is rev 997)
  6. svn sw ^/branch1a to get back to the intended branch
  7. svn merge -c 991,994,995 . to bring the reverted changes here
  8. svn ci . to commit the revisions to the repo.

I'm just a little worried that when it comes time to merge branch1a back into branch1, revision 997 will get in the way and prevent a good merge. If someone gives a good answer of a good resolution, I'll be happy to select that answer over this one (which is partial until I actually get to import the revs).

Upvotes: 1

Related Questions