在 Eclipse 中使用 svn 回滚错误的更改

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35983/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:22:12  来源:igfitidea点击:

Rolling back bad changes with svn in Eclipse

eclipsesvnsubclipsesubversive

提问by Juha Syrj?l?

Let's say I have committed some bad changes to Subversion repository. Then I commit good changes, that I want to keep.

假设我对 Subversion 存储库进行了一些错误的更改。然后我提交了我想保留的好的更改。

What would be easiest way to roll back those bad changes in Eclipse, and keep the good changes? Assuming that files relating to bad changes are not same as those relating to the good changes. How things change if good changes were made to same files as bad changes?

在 Eclipse 中回滚那些不好的更改并保留好的更改的最简单方法是什么?假设与不良更改相关的文件与与良好更改相关的文件不同。如果对相同的文件进行好的更改与坏的更改,情况会如何变化?

I am mostly looking a way to do this via Eclipse plugins (Subclipse or Subversive) but commandline commands are also interesting.

我主要是在寻找一种通过 Eclipse 插件(Subclipse 或 Subversive)来做到这一点的方法,但命令行命令也很有趣。

采纳答案by Fernando Barrocal

You have two choices to do this.

您有两种选择来执行此操作。

The Quick and Dirty is selecting your files (using ctrl) in Project Explorer view, right-click them, choose Replace with...and then you choose the best option for you, from Latest from Repository, or some Branchversion. After getting those files you modify them (with a space, or fix something, your call and commit them to create a newer revision.

Quick and Dirty 是ctrl在 Project Explorer 视图中选择您的文件(使用),右键单击它们,选择Replace with...然后选择最适合您的选项,来自Latest from Repository或某个Branch版本。获取这些文件后,您可以修改它们(使用空格或修复某些内容,调用并提交它们以创建更新的修订版。

A more clean way is choosing Mergeat team menu and navigate through the wizard that will help you to recovery the old version in the actual revision.

更简洁的方法是Merge在团队菜单中选择并浏览向导,这将帮助您在实际修订中恢复旧版本。

Both commands have their command-line equivalents: svn revertand svn merge.

这两个命令都有它们的命令行等效项:svn revertsvn merge.

回答by kirlich

In Eclipse Ganymede (Subclipse)

在 Eclipse Ganymede (Subclipse) 中

Select project/file that contains bad change, and from pop-up menu choose:

选择包含错误更改的项目/文件,然后从弹出菜单中选择:

Team -> Show History

团队 -> 显示历史

Revisions related to that project/file will be shown in History tab.

与该项目/文件相关的修订将显示在“历史记录”选项卡中。

Find revision where "bad changes" were committed and from pop-up menu choose:

查找提交了“错误更改”的修订版本,然后从弹出菜单中选择:

Revert Changes from Revision X

还原修订版 X 的更改

This will merge changes in file(s) modified within bad revision, with revision prior to bad revision.

这将合并在错误修订中修改的文件中的更改,与错误修订之前的修订。

There are two scenarios from here:

这里有两种情况:

  1. If you committed no changes for that file (bad revision is last revision for that file), it will simply remove changes made in bad revision. Those changes are merged to your working copy so you have to commit them.

  2. If you committed some changes for that file (bad revision is not last revision for that file), you will have to manually resolve conflict. Let say that you have file readme.txt with, and bad revision number is 33. Also, you've made another commit for that file in revision 34. After you choose Revert Changes from Revision 33you will have following in your working copy:

  1. 如果您没有为该文件提交任何更改(错误修订是该文件的最后修订),它将简单地删除在错误修订中所做的更改。这些更改将合并到您的工作副本中,因此您必须提交它们。

  2. 如果您为该文件提交了一些更改(错误的修订不是该文件的最新修订),您将不得不手动解决冲突。假设您有 readme.txt 文件,并且错误的修订号是 33。此外,您已经在修订版 34 中为该文件进行了另一次提交。选择Revert Changes from Revision 33后,您的工作副本中将包含以下内容:

readme.txt.merge-left.r33- bad revision

readme.txt.merge-left.r33- 错误修订

readme.txt.merge-right.r32- before bad revision

readme.txt.merge-right.r32- 修改前

readme.txt.working- working copy version (same as in r34 if you don't have any uncommitted changes)

readme.txt.working- 工作副本版本(如果您没有任何未提交的更改,则与 r34 中的相同)

Original readme.txt will be marked conflicted, and will contain merged version (where changes from bad revision are removed) with some markers (<<<<<<< .working etc). If you just want to remove changes from bad revision and keep changes made after that, then all you have to do is remove markers. Otherwise, you can copy contents from one of 3 files mentioned above to original file. Whatever you choose, when you are done, mark conflict resolved by

原始 readme.txt 将被标记为冲突,并将包含带有一些标记(<<<<<<< .working 等)的合并版本(其中删除了错误修订的更改)。如果您只想从错误的修订版中删除更改并保留之后所做的更改,那么您所要做的就是删除标记。否则,您可以将上述 3 个文件之一的内容复制到原始文件中。无论您选择什么,完成后,标记冲突已解决

Team - Mark Resolved

团队 - 马克解决

Temporary files will be removed and your file will be marked changed. As in 1, you have to commit changes.

临时文件将被删除,您的文件将被标记为已更改。与 1 一样,您必须提交更改。

Note that this does not remove revision from revision history in svn repository. You simply made new revision where changes from bad revision are removed.

请注意,这不会从 svn 存储库的修订历史记录中删除修订。您只是进行了新修订,其中删除了错误修订的更改。

回答by Matt

If you want to do 1 file at a time you can go to the History view for the file assuming you have an Eclipse SVN plugin installed. "Team->Show History"

如果您想一次执行 1 个文件,则可以转到该文件的历史记录视图,前提是您安装了 Eclipse SVN 插件。“团队->显示历史”

In the History view, find the last good version of that file, right click and choose "Get Contents". This will replace your current version with that version's contents. Then you can commit the changes when you've fixed it all up.

在历史视图中,找到该文件的最后一个好的版本,右键单击并选择“获取内容”。这将用该版本的内容替换您当前的版本。然后您可以在修复所有更改后提交更改。

回答by Tuukka Mustonen

In Eclipse using Subversive:

在 Eclipse 中使用 Subversive:

Right click your project > Team > Merge

右键单击您的项目 > 团队 > 合并

In the merge window, select the revisions you want to revert as normally but also enable checkbox "Reversed merge".

在合并窗口中,选择要正常恢复的修订版,同时启用“反向合并”复选框。

Merge as normally.

像往常一样合并。

回答by Mark Phippard

I have written a couple of blog posts on this subject. One that is Subclipse centric: http://markphip.blogspot.com/2007/01/how-to-undo-commit-in-subversion.htmland one that is command-line centric: http://blogs.collab.net/subversion/2007/07/second-chances/

我已经写了几篇关于这个主题的博客文章。一个是Subclipse的中心的:http://markphip.blogspot.com/2007/01/how-to-undo-commit-in-subversion.html和一个是命令行中心的:HTTP://blogs.collab。 net/subversion/2007/07/second-chances/

回答by Nick Higgs

The svnbook has a section on how Subversion allows you to revert the changes from a particular revision without affecting the changes that occured in subsequent revisions:

svnbook 有一节介绍了 Subversion 如何允许您从特定修订版恢复更改,而不会影响后续修订版中发生的更改:

http://svnbook.red-bean.com/en/1.4/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.undo

http://svnbook.red-bean.com/en/1.4/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.undo

I don't use Eclipse much, but in TortoiseSVN you can do this from the from the log dialogue; simply right-click on the revision you want to revert and select "Revert changes from this revision".

我不经常使用 Eclipse,但在 TortoiseSVN 中,您可以从日志对话中执行此操作;只需右键单击要还原的修订,然后选择“从该修订还原更改”。

In the case that the files for which you want to revert "bad changes" had "good changes" in subsequent revisions, then the process is the same. The changes from the "bad" revision will be reverted leaving the changes from "good" revisions untouched, however you might get conflicts.

如果您要还原“坏更改”的文件在后续修订中具有“好的更改”,则过程相同。“坏”修订版的更改将被还原,而“好”修订版的更改将保持不变,但是您可能会遇到冲突。

回答by Gora

I have same problem but CleanUp eclipse option doesn't work for me.

我有同样的问题,但 CleanUp eclipse 选项对我不起作用。

1) install TortoiseSVN
2) Go to windows explorer and right click on your project directory
3 Choice CleanUp option (by checking break lock option)

1) 安装 TortoiseSVN
2) 转到 Windows 资源管理器并右键单击您的项目目录
3 选择清理选项(通过检查中断锁定选项)

It's works.

其作品。

Hope this helps someone.

希望这可以帮助某人。