撤回意外签到 [英] Retract accidental checkin
问题描述
您正在使用 subversion,并且在准备就绪之前不小心签入了一些代码.例如,我经常:a) 签入一些代码,然后 b) 稍微编辑一下,然后 c) 敲击,回车以重复上一个不幸签入的命令.
You're using subversion and you accidentally checkin some code before it's ready. For example, I often: a) checkin some code, then b) edit a little, then c) hit up, enter to repeat the previous command which unfortunately was a checkin.
是否可以通过 subversion 从服务器撤回这种意外签入?
Is it possible to retract such an accidental checkin from the server with subversion?
推荐答案
注意:这可能不适用于当前版本的 SUBVERSION 并且是一个糟糕的想法 - 但我把它留在这里以供参考强>
注意: 通常,当您错误签入时,您应该只恢复提交 - 请参阅此问题的其他答案.但是,如果您想知道如何实际撤消提交的影响并将存储库更改为以前的状态,请在下面进行一些说明:
这不是您通常想要的,但是如果您真的想从存储库中删除实际提交的版本,那么您可以按如下方式对存储库进行讨厌的回滚(这假设$REV
设置为您要删除的最新版本):
This isn't what you normally want, but if you really want to remove the actual committed version from the repository, then you can do a nasty rollback on the repository as follows (this assumes that $REV
is set to the latest revision, which you are removing):
- 首先备份您的存储库,因为这些更改可能会破坏它(并阅读下面的假设)
- 将您的本地副本恢复到以前的版本,以免混淆 (
svn revert -r $((REV-1))
) - 在存储库中,删除
db/revs/$REV
和db/revprops/$REV
- 在存储库中,删除
db/current
和(对于 subversion 1.6 或更高版本)db/rep-cache.db
,然后运行 svnadmin recover .
- (可能)调整
db/rep-cache.db
的权限以防止尝试写入只读数据库 错误
- Backup your repository first as these changes may break it (and read the assumptions below)
- Revert your local copy to the previous revision so it doesn't get confused (
svn revert -r $((REV-1))
) - In the repository, remove
db/revs/$REV
anddb/revprops/$REV
- In the repository, remove
db/current
and (for subversion 1.6 or greater)db/rep-cache.db
, and runsvnadmin recover .
- (Possibly) adjust the permissions on
db/rep-cache.db
to prevent attempt to write a readonly database errors
这一切都假设:
- 您正在使用基于
fsfs
的存储库 - Subversion 版本高于
1.5.0
(否则您必须手动编辑db/current
并更改修订号而不是运行svnadmin recover .
代码>) - 未提交其他后续修订
- 您对存储库的文件系统具有写入权限
- 在执行上述操作时,您不会害怕其他人试图访问它
- You're using a
fsfs
-based repository - Subversion release greater than
1.5.0
(otherwise you have to manually editdb/current
and change the revision number rather than runningsvnadmin recover .
) - No other subsequent revisions have been committed
- You have write access to the filesystem of the repository
- You aren't scared of somebody else trying to access it while you do the above
当一个巨大的文件被提交到一个我不想永远留在历史(和镜像等)中的存储库时,我已经做到了;这绝不是理想或正常的做法...
I've done it when a huge file was committed to a repository that I didn't want to stay in the history (and mirrors etc) forever; it's not in any way ideal or normal practice...
这篇关于撤回意外签到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!