你使用subversion,你不小心签入一些代码之前准备好。例如,我经常:签入一些代码,然后b)编辑,然后c)点击,输入重复前面的命令,不幸的是签入。
有可能收回这些意外签入和subversion服务器吗?
你使用subversion,你不小心签入一些代码之前准备好。例如,我经常:签入一些代码,然后b)编辑,然后c)点击,输入重复前面的命令,不幸的是签入。
有可能收回这些意外签入和subversion服务器吗?
<强>注:这可能不会工作在当前版本的颠覆和是一个坏主意,但是我已经离开这里的信息< /强>
<强>注:< /强> < em >通常当你有检查的错误,你应该回复提交——看到其他的回答这个问题。然而,如果你想知道如何撤销提交的影响和改变存储库之前,有一些解释如下:< / em >
不是你通常想要的是什么,但如果你真的<强> < /强>想要删除的实际版本的库,那么你可以做一个讨厌的回滚的库,如下所示(这里假设<代码> < /代码>牧师将美元最新修订,要删除):
svn revert -r $((REV-1))
)db/revs/$REV
and db/revprops/$REV
db/current
and (for subversion 1.6 or greater) db/rep-cache.db
, and run svnadmin recover .
db/rep-cache.db
to prevent attempt to write a readonly database errors 这所有的假设:
fsfs
-based repository1.5.0
(otherwise you have to manually edit db/current
and change the revision number rather than running svnadmin recover .
)我已经做了一个巨大的文件被提交到存储库,我并不想永远留在历史(和镜子等);它以任何方式不理想或正常的实践……
看到< 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:
把你回购。
使用< 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管理工具来摆脱签入。
把它回回购。
但这完全可以毁了你的回购,所以从来没有尝试这样做,除非你完全知道自己在做什么,一切都备份。
你不能删除修改——几个答案似乎完全误解你想要什么。但是你可以改变签入消息表明它是意想不到的。签到不非常有奇怪的额外成本是没什么大不了的。
是的,这是真正颠覆。
你需要做的只是更换你的复制与先前的版本在SVN库中。
有几种选择:
但我强烈建议你做以下之前取代你的本地副本:
有时需要在服务器上编辑回购,例如当你已经不小心犯了一个密码,很难改变。这年代的方法我认为是完全安全的(答案@David弗雷泽回购为我腐败引起)。NB这种方法只会把修订从回购的结束也是最有用的立即如果你注意到你的错误。
svnadmin dump -r 0:N > reponame.dump
svnadmin dump -r 0:6610 > reponame.dump
will remove revs 6611 onwardssvnadmin create reponame
svnadmin load reponame < reponame.dump
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