How to remove 1 revision of a folder in Subversion

10,118

Solution 1

  1. Do an update to make sure your working copy is up to date. Make sure your working copy is clean, without pending modifications.
  2. Right click on the root folder of your project's working copy and "show log"
  3. Select (with ctrl/shift to select multiple) the revisions you want to undo
  4. Right click the selected revisions and "revert changes from these revisions"
  5. Check the modifications that the undo operation has made on your working copy. Resolve any conflicts if necessary.
  6. Commit the modifications

The answer by Gabriel Hurley that you have currently had accepted doesn't make sense: it is not possible to commit after doing an "update to revision". That operation rolls back the BASE revision that your working copy is based on. When trying to commit changes, subversion will then complain that the files and folders are out of date.

You want the revert to revision or revert changes from revision features, not "update to revision".

Solution 2

Short answer, you don't. It's really hard to actually erase a commit from a subversion repo. Intentionally so.

Practically, the thing to do is revert that directory back to revision 49, and then commit it as rev 61.

The key thing is that you're reverting ONLY the directory in question, not the whole checkout.

Here's the relevant SVN book link: http://svnbook.red-bean.com/en/1.0/svn-book.html#svn-ch-4-sect-4.2

You want a command of the form "svn merge -r 60:50 xxx://path"

Solution 3

You go back and get the file at the state it was in at revision 50 (using "update to revision"), then re-merge it with the current version if there have been any subsequent changes you want to keep. Otherwise you can just do your update to revision, then recommit the file.

There's no automatic way to do this, but with a little work by hand it's doable. That's the magic of version control.

Solution 4

if you do want changes 51:60

svn merge -r 50:49 A/trunk/
#the most painful experience in your life
svn commit -m "reverting to rev49"

Note that this often just does not work.

if you do want changes 51:60, manual way

svn diff -r 50:49 A/trunk/
#review changes from the diff and apply them. or patch.
svn commit -m "reverting to rev49"

Solution 5

All the other answers are good if you have a change that you want undone, without touching any other changes that have happened on the same folder.

If I understand your use case correctly, you are not worried about other changes on project A, because there are none. You simply want project A to go back to how it was before revision 50. If that is the case, then there is a much simpler solution (and with much less grief then doing merges and conflict resolution):

svn del full://url/to/project/A
svn cp full://url/to/project/A@49 full://url/to/project/A

This basically "removes" the current HEAD of project A from the repository (it is still in the history) and then copies an older copy of the project (from before the problematic commit) over instead.

This procedure is so transparent that if someone with a checkout of A (from revision 50 or later) does an svn update, they will be updated to the latest revision with no fuss at all. No merging to fight with or anything.

Share:
10,118
vikas mehta
Author by

vikas mehta

Updated on June 14, 2022

Comments

  • vikas mehta
    vikas mehta almost 2 years

    I have several projects in my repository, each project has it's own folder. Is it possible to remove the last revision of one of the projects without changing anything else?

    Example: Project A's latest version was committed creating rev. 50. Work on other projects goes on, the repository is now at rev. 60.

    Now the user of A comes back and requests to remove the changes of the last version because they don't work out for him. He wants to go back to the previous version and all further changes should be done starting from there.

    At this point I would like rev. 50 to disappear so that project A can go on as if rev. 50 never happened.

    The only way I can see is to create a branch and from now on work on that branch. But that just creates many branches over time and the project's history gets cluttered.

    What is a good solution for this scenario?