Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I've accidentally overwritten an old branch by copying trunk over it using 'svn copy'. More specifically, for every release, trunk is branched and kept as a tag, using:

svn copy svn://machine/REPOS/trunk svn://machine/REPOS/tags/$RELEASENR

But this time the value of 'RELEASENR' was that of an old existing branch instead of a new one. Anybody have any ideas on how to undo this mistake? Thanks already!

Subversion doesn't work that way. You haven't actually overwritten it. If the target of the copy or a move exists and is a directory, then the copied or moved item is placed in that directory:

svn copy svn://machine/REPOS/trunk svn://machine/REPOS/tags/EXISTS_ALREADY

If you look, you should find:

svn://machine/REPOS/tags/EXISTS_ALREADY/trunk 

Which is a copy of the trunk you just tried to tag. The fix in this case is easy:

svn mv svn://machine/REPOS/tags/EXISTS_ALREADY/trunk \
       svn://machine/REPOS/tags/CORRECT_TAG_NAME

(In case you're not *nix conversant: The \ means I've broken one logical line into two physical lines to spare your horizontal scrollbar from overwork.)

I suspect that if his procedure is identical for all releases, he has actually overwritten the existing trunk in EXIST_ALREADY directory. – mouviciel Apr 7, 2009 at 9:32 Thanks, this was helpful. However, I chose to undo the cp and re-create the tag, because the commit message was also incorrect (it contained the name of the existing tag instead of the name of the new tag) and because I like to keep the change histories uniform and simple for all tags. To undo the cp: svn co svn://machine/REPOS/tags/EXISTS_ALREADY/ EXISTS_ALREADY, cd EXISTS_ALREADY, svn merge -c -REVISION_OF_INCORRECT_CP ., svn commit. – Chris Page May 13, 2012 at 0:45

You can undo your last revision by merging back to the previous revision. See http://anilsaldhana.blogspot.com/2007/11/svn-undo-change.html

svn merge --revision 92:91 .

and then commit

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.