Search code examples
svnundorevert

Undo SVN 1.6 mistake via command line


I'm using Mac OS X terminal for SVN. I'm very amateur when it comes to SVN and command line. I'm typically just a front-end code monkey.

I've accidentally, somehow, committed some branches of our project inside another branch of the project while attempting to check out the branch. Yes, I'm that bad.

Remote repository:

MyProjectBranch
    BranchNeedsToNotBeHere
    BranchNeedsToNotBeHere2
    BranchNeedsToNotBeHere3
    expectedDirectoryStillHere1
    expectedDirectoryStillHere2
    expectedDirectoryStillHere3

Finally correct local repository at desired revision:

MyProjectBranch
    expectedDirectoryStillHere1
    expectedDirectoryStillHere2
    expectedDirectoryStillHere3

How do I undo this travesty without making myself look incompetent? It would seem like a simple "revert" command would be available, but all I've found is "reverse merging" - which, if I've done that right, hasn't removed the extraneous directories at all, and the expected directories are not at the correct revision, but an older one. So I may not even be doing that right.

Much kudos and, when available, bounty to anyone who can save me!


Solution

  • Revert your commit by doing the following:

    svn merge -c -$REV
    

    where $REV is the change that you introduced the directories. If you did it over a range of revisions repeat this for each revision. Note the dash in front of the revision number, it's a minus to imply the reversal of that revision. If the range of revisions you want to remove is the only things committed on the path you can specify the range with -r $YOUNGEST:$OLDEST instead of -c -$REV instead and do a single reverse merge.

    If everything is limited to just adding new files/directories, you could just also use svn rm on the paths and remove them.