Mercurial:删除后如何恢复部分工作副本

发布于 2024-09-01 17:34:52 字数 66 浏览 6 评论 0原文

我在解决方案中删除了一个项目,提交了多次,现在发现我仍然需要那个已删除的项目。有没有办法在保留历史记录的情况下恢复它?

I deleted a project in my solution, committed many times and now found out that I still need that deleted project. Is there a way to restore it with keeping it's history?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那伤。 2024-09-08 17:34:52

假设删除的内容实际上在存储库中跟踪

hg revert -r (last-revision-where-files-still-existed) path/to/files/that/were/deleted

通过这样做,您只是告诉 Mercurial 恢复这些文件,就像您删除它们时一样。不会恢复其他文件,只需注意正确指定其以前的位置即可。只要回顾一下你的历史,你就会发现这一点。

hg --help revert 的输出:

如果文件已被删除,则
恢复了。如果a的可执行模式
文件已更改,已重置。

供参考(选项)[-r 是您想要的]:

options:

 -a --all        revert all changes when no arguments given
 -d --date       tipmost revision matching date
 -r --rev        revision to revert to
    --no-backup  do not save backup copies of files
 -I --include    include names matching the given patterns
 -X --exclude    exclude names matching the given patterns
 -n --dry-run    do not perform actions, just print output

use "hg -v help revert" to show global options

Assuming what was deleted was actually tracked in the repository:

hg revert -r (last-revision-where-files-still-existed) path/to/files/that/were/deleted

By doing this, you are simply telling mercurial to bring back those files, as they were when you deleted them. No other files will be reverted, just take care to specify their previous locations correctly. You can find that just going through your history.

From the output of hg --help revert :

If a file has been deleted, it is
restored. If the executable mode of a
file was changed, it is reset.

And for reference (the options) [-r is what you want here]:

options:

 -a --all        revert all changes when no arguments given
 -d --date       tipmost revision matching date
 -r --rev        revision to revert to
    --no-backup  do not save backup copies of files
 -I --include    include names matching the given patterns
 -X --exclude    exclude names matching the given patterns
 -n --dry-run    do not perform actions, just print output

use "hg -v help revert" to show global options
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文