How to revert (roll back) to a previous revision with Subversion
You would think that reverting to a previous version of your application would be one of the key use cases for a version control system like Subversion and that it would be trivial to do, but it's actually not intuitive at all.
When I was first starting out with Subversion, I thought there would be a revert
command that took a revision as an argument and basically rolled back your application to revision X. Alas, there is a revert
command in SVN, but instead of reverting to a previous revision, it works to undo any local changes you've made to your working copy.
Here, then, is a very simple, plain English explanation of how to revert to a previous version of your application in Subversion, to help anyone who may be starting out with it and is lost.
To revert to a previous version of your application (roll back changes) in Subversion, you merge the changes from your current revision back to the revision you want to revert to. So, for example, if you want to revert the trunk of your application from revision 73 to 68, you would do the following:
svn merge --dry-run -r:73:68 http://my.repository.com/my/project/trunk
svn merge -r:73:68 http://my.repository.com/my/project/trunk
svn commit -m "Reverted to revision 68."
Step 1 will perform a dry run and show you what the merge will produce. If you want to see exactly what changes will be applied, do a diff:
svn diff -r:73:68 http://my.repository.com/my/project/trunk
Step 2 actually performs the merge (you'd do this after you're happy with the dry run). At this point, realize what is happening: Subversion is calculating the changes between revision 73 and revision 68 of the trunk and applying them to your working copy. For the majority of the time, you will thus want your working copy to be a fully updated copy of the revision you are reverting from (in this example, revision 73).
Finally, since the merge happens on your local working copy, you need to commit it to the repository in Step 3.
Comments
by Mike on 2008-06-23 17:03:14
by Boaz on 2008-09-22 07:38:15
by Steve Mactaggart’s Blog » Blog Archive » links for 2009-05-08 on 2009-05-09 04:31:25
by Victor on 2008-10-16 06:27:15
by David on 2008-06-24 13:21:00
by Alan Haggai Alavi on 2009-02-06 18:28:00
by Ben on 2008-06-22 17:00:18
by Borek on 2008-06-22 17:51:38
by pan69 on 2008-06-23 07:07:50
by Nayan Hajratwala on 2009-04-07 20:59:10
by DannyT on 2008-06-25 09:42:00
by Aral on 2008-06-26 08:00:31
by ash on 2008-09-26 10:01:38
by Max on 2008-07-30 18:55:00
by Sandro on 2008-08-20 19:30:39
by El Demonio on 2008-12-09 18:50:09
by chris breshears on 2008-06-22 15:48:44
by Aral on 2008-06-26 08:00:50
by Michiel van der Ros on 2008-06-23 12:15:36
by Luke Bayes on 2008-06-23 15:44:16
by Vinayak on 2008-10-16 18:09:05
by Amrac on 2008-11-01 00:23:32
by Mohit on 2009-01-28 12:53:13
by Sven Bachmann on 2009-05-15 11:12:42
by Miromedia Search Engine Optimisation Blog - Rollback a Subversion commit on 2009-01-20 13:15:25
by petke on 2009-01-21 11:10:32
by Rob Searles on 2009-02-02 12:39:01
by Paul Pladijs on 2009-06-18 17:50:23
by Chris on 2009-10-30 02:53:57
by Aditya on 2009-11-12 14:45:07
by Nate on 2009-08-17 16:26:50
by yungchin on 2009-08-05 23:05:32
by Alphonse on 2009-09-22 10:29:08
by Tiago Almeida on 2009-09-16 12:33:30
by Synchronizing Wordpress or website with SVN | satf on 2009-08-16 21:19:16
by Vijay Dev on 2009-11-13 07:20:40
by John Malcolm on 2009-12-03 01:19:39
by Christian on 2009-12-04 16:31:13
by Blah on 2009-12-13 01:52:33
by William Notowidagdo on 2009-12-16 16:14:45
by Khosrow on 2010-01-14 13:55:08
by Sid on 2010-01-14 12:59:35
by ferg on 2010-01-19 23:27:43
by Konstantin Boyanov on 2010-01-20 10:56:54
by Michael Rice on 2010-01-21 03:51:44
by Revert or rollback a SVN revision « Magp.ie on 2010-03-25 18:47:08
by isam on 2010-02-09 16:42:54
by isam on 2010-02-09 16:35:55
by Andrew Blair on 2010-01-26 18:23:03
by Somdas on 2010-03-29 17:29:49
by Best of all... on 2010-03-17 21:40:03
by Geddon on 2010-02-03 15:16:58
by Geddon on 2010-02-03 15:30:22
by danielsdesk on 2010-02-22 16:47:19
by Jimish Shah on 2010-02-17 13:54:32
by jeff on 2010-02-18 18:36:36
by shridhar on 2010-02-19 19:23:44
by lensovet on 2010-03-01 21:42:39
by Kalle on 2010-03-03 15:21:21
by Jamie Saunders on 2010-03-11 17:10:46
by Andrew on 2010-03-12 19:53:06
by Source Control Nightmare « Tales of an Ex-Googler on 2010-04-28 02:03:24
by colin on 2010-04-20 16:35:41
by Rodolfo Carvajal on 2010-03-22 16:20:06
svn: Syntax error in revision argument ':29:27'
. Proper usage would besvn merge -r 73:68 http://my.repository.com/my/project/trunk
.by Ain Tohvri on 2010-04-06 11:09:54
by Ben on 2010-04-22 22:45:19
by Andri on 2010-05-30 12:04:25
by Closer To The Ideal » Blog Archive » How to roll back your changes in Subversion on 2010-04-30 21:34:01
by mike on 2010-06-21 17:17:20
by Abhijeet Anand on 2010-06-22 12:15:34
by NicolasB on 2010-06-15 17:24:53
by Adrie on 2010-08-18 08:26:27
by Dennison Uy on 2010-08-11 09:17:02
by Dennis Gearon on 2010-07-22 14:34:20
by Rastin Mehr on 2010-08-14 23:18:36
by Carl Helmertz on 2010-08-16 08:46:46
by David on 2010-11-04 15:39:44
by Gavin on 2010-09-01 08:53:59
by paul haine on 2010-08-18 16:54:56
by paul haine on 2010-08-18 16:55:45
by Jonathan on 2010-10-18 17:21:27
by Niels Bjerg on 2010-09-22 08:42:09
by Yonas on 2010-10-08 16:18:40
by Steven on 2010-08-24 12:54:27
by Kvex on 2010-10-12 08:13:17
by Sandeep Sripada on 2010-09-29 21:34:48
by David Hallett on 2010-11-01 12:11:13
by Thuy on 2010-12-03 23:43:33
by Trevor on 2010-12-15 01:39:34
by Jonathan on 2010-12-15 17:18:54
by vdevi on 2011-01-25 18:17:56
by Jonny Olliff-Lee on 2011-02-07 15:06:21
by Ivan Vučica on 2011-01-11 20:30:53
by _ on 2011-02-01 22:58:06
by adrianbj on 2011-03-03 02:17:58
by Donal on 2011-02-14 09:49:05
by Nick on 2011-02-23 17:11:21
by Panikos on 2011-03-07 16:39:04
by Robert Nelson on 2011-02-20 07:10:22
by Ed on 2011-02-22 09:53:09
by mc on 2011-03-09 16:18:07
by Ian Hickman on 2011-03-09 17:09:19
by Nikola on 2011-04-28 10:27:48
by Vlad on 2011-03-03 10:53:18
by Philip Thompson on 2011-02-21 19:45:47
by What Haveyou on 2011-03-09 01:48:02
by Jeune on 2011-04-11 02:35:17
by Gijs on 2011-02-28 11:06:08
by Idomeneo on 2011-04-19 14:04:23
by Ian Hickman on 2011-03-09 17:10:53
by Eugene Kerner on 2011-04-22 16:46:11
by Bill Milligan on 2011-04-15 15:11:32
by Hamid on 2011-08-28 08:43:52
by hadv on 2011-06-28 10:29:34
by Mick on 2011-06-13 13:18:14
by Karl on 2011-05-23 20:13:19
by Dave on 2011-05-13 04:55:36
by Ned Seagoon on 2011-09-16 00:47:46
by Dmitri on 2011-07-29 20:22:14
by Aral Balkan · How to revert (roll back) to a previous revision with Subversion « ontheeasiestway on 2011-05-30 03:07:07
by rudraksha on 2011-05-31 11:31:41
by Harsha on 2011-05-16 21:53:24
by Jim McIntyre on 2011-06-16 17:24:18
by jmanuel on 2011-06-03 09:59:13
by James on 2011-05-19 18:44:19
by manoj on 2011-06-21 14:43:33
by Robert Rath on 2011-05-25 06:01:11
by Sean on 2011-06-27 20:24:03
by Scott on 2011-07-13 18:41:03
by john on 2011-09-20 06:05:18
by mka on 2011-07-01 09:39:20
by Adrien on 2011-07-20 06:08:51
by David on 2011-08-10 06:47:50
by JuanPi on 2011-08-08 09:04:45
by David on 2011-08-10 06:50:42
by Marked One on 2011-08-13 16:08:30
by ommrudraksha on 2011-08-29 05:10:56
by A B on 2011-08-15 22:55:32
by Yogesh on 2011-09-30 13:16:29
by Rod McLaughlin on 2011-10-26 21:00:50
by Rijk Stofberg on 2011-10-26 10:33:29
by Ankit Jhalaria on 2011-12-05 18:15:54
by Erik on 2012-01-19 10:03:52
by Rem's on 2011-12-02 12:41:24
by Flimm on 2011-11-07 12:05:18
by Flimm on 2011-11-07 12:11:12
by Avinash Pawar on 2011-12-15 06:35:59
by Steven J. Garner on 2012-02-18 00:36:42
by Gus on 2011-12-16 15:59:16
by Tolga AKIN on 2012-01-18 18:10:28
by Vibhor on 2012-03-05 09:14:43
by mike on 2012-01-23 22:21:04
by Mauritz Hansen on 2012-02-24 11:46:35
by illo on 2012-01-25 18:38:08
by Shankari on 2012-01-13 06:36:16
by izar on 2011-12-29 16:55:32
by Stefan on 2012-02-29 16:42:52
by Alex on 2012-03-01 00:12:42
by Mitch Robertson on 2012-02-01 00:57:24
by David on 2012-01-16 13:33:27
by ionut on 2012-01-16 15:57:01
by Oyvind on 2012-01-20 07:39:03
by ionut on 2012-01-16 15:58:19
by Mohammad Khashashneh on 2012-02-22 16:27:46
by Joar on 2012-05-25 09:56:13
by Kris on 2012-05-29 18:58:35
by Georgie on 2012-06-18 02:35:36
by mofolo on 2012-07-19 18:17:10
by Echo on 2012-09-12 11:42:33
by hurin on 2012-10-08 08:44:52
by Alexis Wilke on 2012-09-06 06:06:09
by Laszlo on 2012-10-17 14:23:31
by Steve K on 2012-10-19 19:23:09
by Steve K on 2012-10-19 19:25:28
by Phil on 2012-10-16 15:18:06
by georgi on 2012-10-07 14:43:14
by GiD on 2012-12-04 14:46:23