English 中文(简体)
收回意外签入
原标题:
  • 时间:2009-04-14 14:04:35
  •  标签:

你使用subversion,你不小心签入一些代码之前准备好。例如,我经常:签入一些代码,然后b)编辑,然后c)点击,输入重复前面的命令,不幸的是签入。

有可能收回这些意外签入和subversion服务器吗?

最佳回答

<强>注:这可能不会工作在当前版本的颠覆和是一个坏主意,但是我已经离开这里的信息< /强>

<强>注:< /强> < em >通常当你有检查的错误,你应该回复提交——看到其他的回答这个问题。然而,如果你想知道如何撤销提交的影响和改变存储库之前,有一些解释如下:< / em >

不是你通常想要的是什么,但如果你真的<强> < /强>想要删除的实际版本的库,那么你可以做一个讨厌的回滚的库,如下所示(这里假设<代码> < /代码>牧师将美元最新修订,要删除):

  • 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 and db/revprops/$REV
  • In the repository, remove db/current and (for subversion 1.6 or greater) db/rep-cache.db, and run svnadmin recover .
  • (Possibly) adjust the permissions on db/rep-cache.db to prevent attempt to write a readonly database errors

这所有的假设:

  • You re using a fsfs-based repository
  • Subversion release greater than 1.5.0 (otherwise you have to manually edit db/current and change the revision number rather than running svnadmin 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

我已经做了一个巨大的文件被提交到存储库,我并不想永远留在历史(和镜子等);它以任何方式不理想或正常的实践……

问题回答

看到< a href = " http://svnbook.red-bean.com/en/1.8/svn.branchmerge.basicmerging.html svn.branchmerge.basicmerging.undo”rel = " noreferrer " > SVNBook < / >,特别是取消更改部分,和反向合并。

svn合并的另一个常见用法是回滚已经提交的改变。假设你工作愉快地在一个工作副本/钙/树干,你发现改变了早在303年修订,这改变了整数。c,是完全错误的。它不应该被提交。您可以使用svn合并“撤销”的改变你的工作副本,然后提交本地修改存储库。所有您需要做的就是指定一个反向的区别:

美元svn合并- r 303:302 < a href = " http://svn.example.com/repos/calc/trunk " rel = " noreferrer " > http://svn.example.com/repos/calc/trunk < / >

澄清一下,你最初的变化将< em >仍然是在存储库中< / em >。但你现在已经收回了它在以后的修订。即存储库中已经占据了你所有的改变(这是你真正想要的!除非你已经签入一个明文密码或类似的!)

< /强> <强>警告:接受答案(大卫·弗雷泽)应与一个SVN 1.5库,但与SVN 1.6还必须删除<代码> db / rep-cache。db > < /代码在下次提交或<强>你会腐败的存储库< / >强,可能没有意识到它直到你下次尝试完成付款。我已经见过后续完成签出失败的“畸形表示头”的错误。

什么是rep-cache。德国联邦铁路(db),你可能会问?< a href = " https://svn.apache.org/repos/asf/subversion/trunk/subversion/libsvn_fs_fs/structure " rel = " noreferrer " >文档fsf布局< / >说,你将失去“rep-sharing能力”如果你删除这个文件;但是,它将在你的下一个重新提交。< a href = " http://subversion.apache.org/docs/release-notes/1.6.html filesystem-improvements”rel = " noreferrer " >代表分享了在1.6 < / >。

使用TortoiseSVN,选择显示日志和定位你想恢复的修订。从上下文菜单中,选择回到这个修订。这个执行反向合并到你的工作副本,所以你必须提交你的工作副本完成操作。

参见< a href = " https://stackoverflow.com/questions/747597/how-do-we-keep-track-of-our-working-copys-branch " >如何跟踪我们的工作副本分支?< / >:-)

If what you meant is, how do I cleanly remove the history of an accidental checkin: This is difficult.

svn does not allow you to undo anything since it saves revisions as changesets. However, there are some tools that let you do almost anything on a dump of a repository. You could:

  1. 把你回购。

  2. 使用< a href = " http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html svn.reposadmin.maint.tk.svndumpfilter”rel = " nofollow noreferrer " > svndumpfilter的< / > < a href = " http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html " rel = " nofollow noreferrer " > < / > svn管理工具来摆脱签入。

  3. 把它回回购。

但这完全可以毁了你的回购,所以从来没有尝试这样做,除非你完全知道自己在做什么,一切都备份。

你不能删除修改——几个答案似乎完全误解你想要什么。但是你可以改变签入消息表明它是意想不到的。签到不非常有奇怪的额外成本是没什么大不了的。

是的,这是真正颠覆。

你需要做的只是更换你的复制与先前的版本在SVN库中。

有几种选择:

  1. Replace with Revision.
  2. Replace with URL
  3. Latest from repository (but in your case, you already have the latest)
  4. Replace with Branch

但我强烈建议你做以下之前取代你的本地副本:

  1. Do a Compare with Repository/ Revision / URL .

有时需要在服务器上编辑回购,例如当你已经不小心犯了一个密码,很难改变。这年代的方法我认为是完全安全的(答案@David弗雷泽回购为我腐败引起)。NB这种方法只会把修订从回购的结束也是最有用的立即如果你注意到你的错误。

  1. Inform all your users that the repo is going offline and that they ll need to create a new checkout from the server.
  2. Take the repo offline, take a backup copy and move the main repo to a safe location with a name like reponame_old.
  3. Dump your repo to a single-file representation, leaving the unwanted revisions off the end:
    • svnadmin dump -r 0:N > reponame.dump
    • e.g. svnadmin dump -r 0:6610 > reponame.dump will remove revs 6611 onwards
    • Note that the repodump file could be twice the size of your repo folder.
  4. Create a new repo to load these revisions into:
    • svnadmin create reponame
  5. Load the trimmed set of revisions into the new repo
    • svnadmin load reponame < reponame.dump
  6. Apply any necessary customisations to your new repo (e.g. hooks) and return it to service.
    • We re using VisualSVN server so had to restore the confVisualSVN-WinAuthz.ini file.
    • We also saw some odd behaviour until we rebooted the server, so VisualSVN may cache the repo state; YMMV with other hosting setups.
  7. Don t forget to either delete the backup with the secret data, or put it somewhere safe.
  8. Tell all the users to do a new svn checkout from the repo server.

我对此表示怀疑。源代码控制的主要观点之一是,存储库不宽松的任何历史。你不能删除历史。最好你能做的就是得到一个旧版本和覆盖当前。但是历史日志仍然显示你的错误。

(顺便你用什么样的IDE会做那样的事吗?)

你最不能撤消修改,你所能做的就是恢复到之前的版本,做另一个签入。

评论:这是一系列命令我在库恢复从修订2回修改1。d需要签入最后虽然。

Last login: Mon Apr 13 16:01:34 on ttys004
[wlynch@orange ~] cd /tmp
[wlynch@orange /tmp] svnadmin create foo
[wlynch@orange /tmp] svn co file:///tmp/foo foo-repo
Checked out revision 0.
[wlynch@orange /tmp] cd foo-repo/
[wlynch@orange foo-repo] ls
[wlynch@orange foo-repo] touch blah
[wlynch@orange foo-repo] touch repl
[wlynch@orange foo-repo] touch bar
[wlynch@orange foo-repo] svn add *
A         bar
A         blah
A         repl
[wlynch@orange foo-repo] svn ci
Adding         bar
Adding         blah
Adding         repl
Transmitting file data ...
Committed revision 1.
[wlynch@orange foo-repo] echo "hi" > bar
[wlynch@orange foo-repo] echo "oh no" > blah
[wlynch@orange foo-repo] svn ci
Sending        bar
Sending        blah
Transmitting file data ..
Committed revision 2.
[wlynch@orange older-foo] svn diff -r 1:2 file:///tmp/foo
Index: bar
===================================================================
--- bar (revision 1)
+++ bar (revision 2)
@@ -0,0 +1 @@
+hi
Index: blah
===================================================================
--- blah    (revision 1)
+++ blah    (revision 2)
@@ -0,0 +1 @@
+oh no

[wlynch@orange foo-repo] svn diff -r 1:2 file:///tmp/foo | patch -R
patching file bar
patching file blah    




相关问题
热门标签