简体   繁体   English

SVN在提交前撤消删除

[英]SVN undo delete before commit

If you delete a directory from an SVN working copy, but haven't committed yet, it's not obvious how to get it back. 如果从SVN工作副本中删除目录但尚未提交,则不清楚如何将其恢复。 Google even suggests "svn undo delete before commit" as a common query when you type "svn undo d", but the search results are unhelpful. 当您输入“svn undo d”时,Google甚至建议“在提交前将svn undo delete”作为常见查询,但搜索结果无益。

edit: I'd like a solution that works in subversion 1.4.4 编辑:我想要一个适用于subversion 1.4.4的解决方案

1) do 1)做

svn revert . --recursive

2) parse output for errors like 2)解析输出错误之类的

"Failed to revert 'dir1/dir2' -- try updating instead."

3) call svn up for each of error directories: 3)为每个错误目录调用svn:

svn up dir1/dir2

svn revert deletedDirectory

Here's the documentation for the svn revert command. 这是 svn revert命令的文档


EDIT 编辑

If deletedDirectory was deleted using rmdir and not svn rm , you'll need to do 如果使用rmdir而不是svn rm删除了deletedDirectory则需要执行此操作

svn update deletedDirectory

instead. 代替。

对我有用的是

svn revert --depth infinity deletedDir

从您删除的目录上方的级别执行(递归)还原操作。

为了使它成为一个单一的衬垫你可以尝试类似的东西:

svn status | cut -d ' ' -f 8 | xargs svn revert

The simplest solution I could find was to delete the parent directory from the working copy (with rm -rf, not svn delete), and then run svn update in the grandparent. 我能找到的最简单的解决方案是从工作副本中删除父目录(使用rm -rf,而不是svn delete),然后在祖父节点中运行svn update。 Eg, if you deleted a/b/c, rm -rf a/b, cd a, svn up. 例如,如果你删除了/ b / c,rm -rf a / b,cd a,svn up。 That brings everything back. 这让一切都恢复了。 Of course, this is only a good solution if you have no other uncommitted changes in the parent directory that you want to keep. 当然,如果您希望保留父目录中没有其他未提交的更改,这只是一个很好的解决方案。

Hopefully this page will be at the top of the results next time I google this question. 希望下次我谷歌这个问题时,这个页面将位于结果的顶部。 It would be even better if someone suggested a cleaner method, of course. 如果有人建议采用更清洁的方法,那会更好。

在提交之前,您可以删除该文件夹并更新父目录:

rm -r some_dir

svn update some_dir_parent

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

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