问题描述
我如何将工作目录状态恢复为从存储库的新克隆中获得的内容(显然,我可以克隆我的存储库,但这似乎有点野蛮。)
How do I get the working directory state back to what it would have been from a new clone of the repository (Obviously I could clone my repository, but that seems a bit savage.)
使用git我会这样做:
With git I'd do:
git clean -xdn (dry-run, to see what I'm about to destroy)
git clean -xdf (force, to actually do it)
我假设可能存在一个微妙的不同水银等价物,但是我找不到它。
And I'm assuming that there's probably a subtly different mercurial equivalent, but I can't find it.
推荐答案
您的 git clean
命令从工作树中删除未跟踪的文件,包括被忽略的文件。等效的Mercurial命令由标准的提供:
Your git clean
command remove untracked files from the working tree, including ignored files. The equivalent Mercurial command is provided by the standard purge extension:
hg clean --all --print
- print 以实际删除文件,删除 - all
以仅删除未跟踪的文件并离开忽略后面的文件。
Remove the --print
to actually delete the files, remove --all
to only delete untracked files and leave ignored files behind.
如果您还想放弃尚未推送的本地变更集,即相当于
If you also want to discard local changesets that haven't been pushed, i.e., the equivalent of
git reset --hard origin/master
那么您需要启用并运行
hg strip "outgoing()"
您本地克隆现在看起来就像您第一次克隆它时一样。
Your local clone will now look just like when you first cloned it.
(是的,我们的工具箱中也有尖锐的工具,但它们隐藏起来,直到您决定使用它们。)
(Yes, we also have sharp tools in our toolbox, but they're hidden away until you decide to use them.)
这篇关于如何使用mercurial进行原始结账?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!