Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In svn, can I revert a change and shelve it for later?

I have some changes commited a few commits back in my svn repository. Let's say HEAD is at r750 and I want to revert r745 without losing r746-r750. Is this possible?

And, can I somehow save r745 and reapply it later (as a new revision)?

like image 582
Grant Avatar asked May 01 '09 22:05

Grant


People also ask

How do I revert changes in SVN?

Revert a File to a Specified RevisionRight-click a file in the Current Folder browser and select Source Control > Revert using SVN. In the Revert Files dialog box, choose a revision to revert to. Select a revision to view information about the change such as the author, date, and log message. Click Revert.

Can we revert 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.

How do I Uncommit files in SVN?

To undo a specific revision you can use the following command: $ svn merge -c -r3745 . In case you have other edited files in working directory, you can commit only the relevant files. Please note that undoing actually will mean you create a new revision with the negatives changes of last commit.


2 Answers

Supposing you get a clean backwards merge, you could do this...

svn merge -r 745:744 <source>

Then when you want to re-apply it, you could forward merge it back in:

svn merge --ignore-ancestry -r 744:745 <source>

For more info, check out the "Common Use-Cases for Merging."

like image 85
Dan Lew Avatar answered Oct 13 '22 01:10

Dan Lew


Yes, this is definitely possible.

When you revert a change, it still creates a new revision in the repository. So you would do something like this:

1) Check out current copy r750.

2) Specify a revert on the working copy using svn merge -r. Your working copy will have the old version merged in.

3) Check in the working copy as r751.

Now you'll have two revisions in the history. The new one (r751) which does not include r745, since you rolled it back. But r745 will still be there if you ever want to reapply it. You can simply check out a copy of r745, merge it into your working copy, and check it back in (say as r752).

like image 42
zombat Avatar answered Oct 13 '22 00:10

zombat