pondermatic
pondermatic

Reputation: 6593

Rolling back an svn move/rename

I absent mindedly mv a folder in my svn trunk instead of branching it. I could just mv it back, but I'm afraid I'd lose history. How is this best undone?

Edit: I should be clear that I did the move on the repository, not my working copy, so it was an automatic commit.

Upvotes: 5

Views: 7765

Answers (4)

bruno
bruno

Reputation: 2273

You better just copy the latest version before the mistaken commit to the same path.

Absently minded move

     svn mv -m 'move it!' \
         http://svn.example.com/repos/calc/trunk \
         http://svn.example.com/repos/calc/foo

Check the log for the latest version before the move

    svn log http://svn.example.com/repos/calc/trunk

...

    ------------------------------------------------------------------------
    r17610 | john.doe | 2017-08-01 11:02:43 -0300 (tue, 01 aug 2017) | 1 line

    move it!
    ------------------------------------------------------------------------
    r17581 | john.doe | 2017-07-31 17:42:57 -0300 (mon, 31 jul 2017) | 1 line

    fix bug
    ------------------------------------------------------------------------

Copy the last good version 17581 to HEAD

 svn mv -m 'fix absently minded move' \
     http://svn.example.com/repos/calc/trunk@17581 \
     http://svn.example.com/repos/calc/trunk

This will fully preserve your history (including the absently minded move)

Upvotes: 0

zellus
zellus

Reputation: 9582

See the subversion manual about Undoing Changes in order to undo your erroneous changes.

You can use svn merge to “undo” the change in your working copy, and then commit the local modification to the repository. All you need to do is to specify a reverse difference. (You can do this by specifying --revision 303:302, or by an equivalent --change -303.)

svn merge -c -303 http://svn.example.com/repos/calc/trunk

Upvotes: 4

radman
radman

Reputation: 18595

If you want to revert so it is as if the move never happened then you need to dump the whole repository up to the revision you want and then recreate the repository.

Check out here and here for details.

Upvotes: 3

Rafe Kettler
Rafe Kettler

Reputation: 76975

If you didn't commit it:

svn revert PATH

Upvotes: 2

Related Questions