SVN Version Rollback Question

别说谁变了你拦得住时间么 提交于 2019-12-22 05:10:06

问题


I'm using SVN (TortoiseSVN) and often came into the following situation:

I wanted to discard any changes since a specific (old) revision and turn all files back to this specific (old) version. Then I wanted to work further as if this specific (old) revision was the newest one, i.e. I wanted to be able to commit the specific old revision as a new revision.

I found several solutions for this problem (for example stackoverflow.com/questions/402159/roll-back-or-revert-entire-svn-repository-to-an-older-revision or rustyrazorblade.com/2007/04/how-to-roll-back-commits-to-an-earlier-version-of-a-repository-in-svn/).

However, I wonder if there is a simple way to roll back to a specific revision. I thought version control is just good for such things (or am I misunderstanding something?).

Is there a simple command/button/etc. that takes an updates my local repository to an old revision and declares it to be the newest one?

Since I suppose that there is no "built-in" function to do this, I wanted to know what reason lead the developers to the decision not to integrate this feature. Does anybody know this?


回答1:


For whatever reason, the SVN folk decided to refer to this as a "Reverse Merge." In the TortoiseSVN Merge dialog, check the Reverse Merge box, and make sure the revisions box reads something like HEAD-324 (where 324 is the version you're going back to).




回答2:


In TortoiseSVN there is an easier (or at least more intuitive IMHO) way to do this. I assume that what it's actually doing behind the scenes is the "reverse merge" that others mentioned.

  1. Right-click on the file/folder you want to roll back.
  2. Click "Show log" from the TortoiseSVN menu.
  3. Select the revision(s) you want to undo.
  4. Right-click on those revisions.
  5. Select "Revert changes from this revision" -- not to be confused with "Revert to this revision"!
  6. Click "Yes"
  7. Remember that this only changes your working copy. Confirm that this did what you expected it to do, and then commit, putting something in your log message about "rolling back" or "reverse merging"



回答3:


I am not sure if I understand you correctly since for example the link you quoted (Roll back or revert entire svn repository to an older revision) already has the solution: reverse merge (as Powerlord mentioned).

From the TSVN merge-documentation:

If you want to merge changes back out of your working copy, to revert a change which has already been committed, select the revisions to revert and make sure the Reverse merge box is checked.

I think the important thing to have in mind is that you do not "rollback the changes" but "merge them out" and then re-commit. You "keep going forward" so to speak (because there is no "reversing" in SVN; it's version control after all, not supposed to "forget things" :)).

If you accidentally committed something that for some reason absolutely cannot be in the repository, you have to (and can) go greater lengths to "get it out again" (also described in the thread you linked: backup and restore).




回答4:


I would move the current trunk into a branch for safe keeping, and then make a copy at the revision number you want back to being the trunk.



来源:https://stackoverflow.com/questions/2477824/svn-version-rollback-question

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!