Difference between revisions of "Undoing-a-commit"

From BRL-CAD
(finish first cut at the example)
(clarify. the change forever lives in history so it can be extracted with svn diff. merge applied to trunk checkout, not trunk itself.)
Line 1: Line 1:
 
= Undoing an svn commit =
 
= Undoing an svn commit =
  
Sometimes one may inadvertently commit a change that was not intended.  For example:
+
Sometimes one may inadvertently commit a change that was not intended or need to revert a change made by someone else because it breaks functionality.  For example:
  
 
  $ svn ci test_vls.c
 
  $ svn ci test_vls.c
 
  ... revision: 9999
 
  ... revision: 9999
  
We want to "uncommit" the change.  But if we don't want to lose the changes we made, we either need to copy the changed file(s) to an unversioned directory '''before''' we do the merge or save the differences '''before''' we commit the merged changes.
+
We want to "uncommit" the change.  First get the URL of the trunk (shortened example):
 
 
First get the URL of the trunk (shortened example):
 
  
 
  $ svn info
 
  $ svn info
Line 22: Line 20:
 
  Last Changed Date: 2012-05-23 15:10:33 -0500 (Wed, 23 May 2012)
 
  Last Changed Date: 2012-05-23 15:10:33 -0500 (Wed, 23 May 2012)
  
Save the changed file(s) if desired.
+
If we don't want to lose the changes we just committed, no worries.  We can copy those file(s) to an unversioned directory '''before''' we do the merge steps below or extract  those changes at any point in the future with the "svn diff" command.  Stash the changed file(s) if desired.
  
 
Do the merge:
 
Do the merge:
Line 29: Line 27:
 
  U  test_vls.c
 
  U  test_vls.c
  
Check that the trunk has changed to the state before the bad commit:
+
That just "merged" the commits from revision 9999 to 9998, which effectively "undoes" 9999.  Check that your trunk checkout has changed back to the state before the bad commit:
  
 
  $ svn diff
 
  $ svn diff
Line 38: Line 36:
 
Commit the change ('''caution''': this will undo local changes that were originally committed!):
 
Commit the change ('''caution''': this will undo local changes that were originally committed!):
  
  $ svn commit -m "Undoing change committed in r9999."
+
  $ svn commit -m "Reverting r9999 because ..."
 
  Sending        test_vls.c
 
  Sending        test_vls.c
 
  Transmitting file data .
 
  Transmitting file data .
 
  Committed revision 10000.
 
  Committed revision 10000.

Revision as of 19:46, 23 May 2012

Undoing an svn commit

Sometimes one may inadvertently commit a change that was not intended or need to revert a change made by someone else because it breaks functionality. For example:

$ svn ci test_vls.c
... revision: 9999

We want to "uncommit" the change. First get the URL of the trunk (shortened example):

$ svn info
Path: .
URL: https://brlcad/svnroot/trunk
Repository Root: https://brlcad/svnroot
Repository UUID: 2f96ce8b-6d43-0410-b8df-bffccc660ffb
Revision: 9999
Node Kind: directory
Schedule: normal
Last Changed Author: tom
Last Changed Rev: 9999
Last Changed Date: 2012-05-23 15:10:33 -0500 (Wed, 23 May 2012)

If we don't want to lose the changes we just committed, no worries. We can copy those file(s) to an unversioned directory before we do the merge steps below or extract those changes at any point in the future with the "svn diff" command. Stash the changed file(s) if desired.

Do the merge:

$ svn svn merge -r9999:9998 https://brlcad/svnroot/trunk
U  test_vls.c

That just "merged" the commits from revision 9999 to 9998, which effectively "undoes" 9999. Check that your trunk checkout has changed back to the state before the bad commit:

$ svn diff
...

Save the diffs if desired.

Commit the change (caution: this will undo local changes that were originally committed!):

$ svn commit -m "Reverting r9999 because ..."
Sending        test_vls.c
Transmitting file data .
Committed revision 10000.