简体   繁体   English

如何撤消svn更新?

[英]How to undo an svn update?

I had modified files in my working directory and did an svn update. 我修改了工作目录中的文件并进行了svn更新。 The update was performed without conflicts. 更新执行时没有冲突。

I would like to be able to revert the working directory content to the state it was just before the svn update. 我希望能够将工作目录内容恢复到svn更新之前的状态。

The reason is because I maintain a local git repository in parallel to the shared svn repository. 原因是因为我与共享的svn存储库并行维护一个本地git存储库。 I forgot to git commit my local changes before doing the svn update. 在执行svn更新之前,我忘了git提交我的本地更改。 Now my working directory contains local changes mixed up with changes resulting from the svn update. 现在,我的工作目录包含与svn更新产生的更改混合的本地更改。 If I commit, all changes will appear as one atomic change. 如果我提交,所有更改将显示为一个原子更改。 I wished they would be separate. 我希望他们能分开。 If I could revert the update and preserve the content of the working directory I had before the svn update, I could do that. 如果我可以恢复更新并保留我在svn更新之前的工作目录的内容,我可以这样做。

I keep hitting this question, and it doesn't actually include the simple answer to the "How to undo an svn update?" 我一直在回答这个问题,它实际上并没有包含“如何撤消svn更新?”的简单答案。 question. 题。

So for the benefit of others, with the solvable case where you just wish to roll back an update: 因此,为了其他人的利益,在可解决的情况下,您只想回滚更新:

First check the log with: 首先检查日志:

svn log | less

This will give you the revision number (eg 957 ) that you wish to go back to. 这将为您提供您希望返回的修订号(例如957 )。 Then: 然后:

svn up -r 957

It's not possible. 这是不可能的。 The state before update is forgotten. 忘记更新前的状态。

You can separate the changes by making subversion diff, using git apply to apply it to index, commit that (your changes) and than commit everything (the changes from pull). 您可以通过使用subversion diff来分隔更改,使用git apply将其应用于索引,提交(您的更改)并提交所有内容(来自pull的更改)。

That is emergency solution. 这是紧急解决方案。 I suggest you switch to git-svn , that will handle this kind of things for you in future. 我建议你切换到git-svn ,将来会为你处理这类事情。

perform an "Update to Version", so you change your local file to stable version and then re-commit. 执行“更新到版本”,因此您将本地文件更改为稳定版本,然后重新提交。 In this way you lose all local changes. 这样你就会失去所有的局部变化。

This is for linux users. 这是针对linux用户的。

Suppose Revisions as follows. 假设修改如下。

Head - 20 Previous revisions to head - 18, 17, 15, 14, 10, 9,8. 头 - 20先前的修订 - 18,17,15,14,10,9,8。

go to your src directory. 转到你的src目录。 Use svn merge -r 17:18 $url 使用svn merge -r 17:18 $ url

$url for your svn base. $ url为你的svn基地。

如果在更新期间发生任何冲突,则会在您的回收站中提供您的文件和修订文件的副本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM