在提交之前,Mercurial丢弃所有添加的文件 [英] mercurial discard all added files prior to a commit
问题描述
只是犯了一个错误,即使用addremove
尝试删除一些未使用hg remove
Just made the mistake of using addremove
to try and remove some files that were deleted without using hg remove
现在有数百个文件将在下一次提交时添加
Now have hundreds of files that are going to be added on the next commit
无论如何,我是否可以快速删除所有这些添加的文件,而不必求助于bash脚本,甚至不必手动hg removing
或forgetting
手动删除每个文件?
Is there anyway I can quickly remove all these added files without having to resort to a bash script or even worse hg removing
or forgetting
each file manually?
推荐答案
如果只想使用内部hg
命令,则可以执行以下操作:
If you want to just use internal hg
commands, you can do the following:
hg forget "set:added()"
这将忘记工作目录中所有标记为已添加"的文件.它利用了Mercurial强大的文件集功能.
Which will forget any file that's marked as "added" in the working directory. It makes use of the rather powerful filesets feature of Mercurial.
在指定文件时可以使用其他过滤器,这使您可以轻松修复其他错误.例如,轻松地重新添加已删除的文件,而仅添加hg add "set:removed()"
.该功能类似于(很简单的)Mercurial revsets ,可以通过以下方法进行研究:
There are additional filters you can use when specifying files, which allows you to easily fix other mistakes. For example, easily re-add removed files but nothing else hg add "set:removed()"
. The functionality is similar to (tho' thankfully simpler than) mercurial revsets, and can be studied with:
hg help filesets
这篇关于在提交之前,Mercurial丢弃所有添加的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!