Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undoing specific revisions in Subversion

Suppose I have a set of commits in a repository folder...

123 (250 new files, 137 changed files, 14 deleted files) 122 (150 changed files) 121 (renamed folder) 120 (90 changed files) 119 (115 changed files, 14 deleted files, 12 added files) 118 (113 changed files) 117 (10 changed files) 

I want to get a working copy that includes all changes from revision 117 onward but does NOT include the changes for revisions 118 and 120.

EDIT: To perhaps make the problem clearer, I want to undo the changes that were made in 118 and 120 while retaining all other changes. The folder contains thousands of files in hundreds of subfolders.

What is the best way to achieve this?

The answer, thanks to Bruno and Bert, is the command (in this case, for removing 120 after the full merge was performed)

svn merge -c -120 . 

Note that the revision number must be specified with a leading minus. '-120' not '120'

like image 585
Ed Guiness Avatar asked Sep 24 '08 10:09

Ed Guiness


People also ask

How do I revert a specific revision in svn?

Right click on the selected revision(s), then select Context Menu → Revert changes from this revision. Or if you want to make an earlier revision the new HEAD revision, right click on the selected revision, then select Context Menu → Revert to this revision. This will discard all changes after the selected revision.

How do I roll back a commit in svn?

To revert a single commit: Go to: Subversion -> Integrate Directory... Show activity on this post. Note that the svn merge command reverts a commit in the sense of having another commit undoing your changes, but keeping your wrong commit in the history.

What does revert in svn do?

Reverts any local changes to a file or directory and resolves any conflicted states. svn revert will not only revert the contents of an item in your working copy, but also any property changes.


1 Answers

To undo revisions 118 and 120:

svn up -r HEAD       # get latest revision svn merge -c -120 .  # undo revision 120 svn merge -c -118 .  # undo revision 118 svn commit           # after solving problems (if any) 

Also see the description in Undoing changes.

Note the minus in the -c -120 argument. The -c (or --change) switch is supported since Subversion 1.4, older versions can use -r 120:119.

like image 126
Bruno De Fraine Avatar answered Oct 21 '22 13:10

Bruno De Fraine