I committed a bunch of files (dozens of files in different folders) by accident. What is the easiest, cleanest (and safest!) way to 'undo' that commit without having to delete the files from my working directory?
Asked
Active
Viewed 5.8k times
3 Answers
156
Go to Show Log Screen, select the revision that you want to undo, right click it and select Revert changes from this revision, this will do a reverse-merge.

bahrep
- 29,961
- 12
- 103
- 150

Christian C. Salvadó
- 807,428
- 183
- 922
- 838
-
8Thats what I was expecting but no sign in the latest tortoise release – Anthony Main Mar 04 '11 at 18:16
-
42Don't forget to commit afterwards, because it just merges locally. – pihentagy Apr 26 '11 at 10:38
-
5Make sure to update your working copy before doing this, otherwise nothing happens. – Florian Brucker Mar 08 '13 at 13:42
-
1Docs on this procedure: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-howto-rollback.html – Costa Oct 18 '13 at 21:21
-
TortoiseSVN > Show Log > – Satyendra Aug 12 '14 at 06:08
-
@FlorianBrucker : Thanks for the note about svn update. svn log showed recent changes but file is not updated and revert was not working. – Makesh Mar 27 '18 at 06:50
-
This doesn’t only undo the commit, because the files are in the state of the commit before and not before the commit. – Quirin F. Schroll Jul 03 '23 at 12:34
15
You may need to use the command line, but you can use the SVN merge command and specify the revisions in reverse to effectively revert a commit. Assuming your bad commit was r1123, you would do:
svn merge -r1123:1122 <url of your working copy>

Peter Mortensen
- 30,738
- 21
- 105
- 131

jcoby
- 4,210
- 2
- 29
- 25
-
Nothing changes when I do like this: svn merge -r 1880:1879 https://server/myproject/branches/problem42 I have tried both with space like this "-r 1880:1879" and without space like this "-r1880:1879". If I run "svn st" afterwards then nothing has changed. – neoneye Dec 04 '12 at 14:45
2
You can revert your working copy to the revision prior to the commit. Once you have reverted your working copy, then simply commit the changes and you will effectively rolled back the accidental commit.
In a case like yours specifically, I would probably check out the revision that I wanted to roll back into a new working copy and then commit the working copy to the head revision.

Peter Mortensen
- 30,738
- 21
- 105
- 131

Noah Goodrich
- 24,875
- 14
- 66
- 96
-
4Would this not tell you that your revision is out of date and require you to update before you commit? I think you need to merge the prior revision rather than just update to the old one. – Mnebuerquo Oct 30 '08 at 01:15
-
1Also, this strategy assumes that the bad commit is the previous one. You may want to undo some changes which happened a while ago, without undoing all of them. – jpaugh Jun 26 '15 at 20:07