如何取消添加已添加的尚未提交的文件?
我输入了 hg add,我是 Mercurial 的新手,结果是一堆 dll、exe、pdb 等都被添加了 还没有提交任何内容,我基本上想撤消添加。 hg忘记的文档不是很清楚不确定这是否是我想要的 如何在下一次提交之前撤消添加
我确实有一些需要添加的实际文件,因此在可以撤消添加之后我将使用带有排除标志的添加
谢谢
I typed in hg add and I am brand new to mercurial and the result of this was a bunch of dll's exe's pdb's etc all got added
Nothing's been committed yet and I basically want to undo the add.
the documentation for hg forget is not very clear not sure if that is want I want
How do I undo the add before the next commit
I do have some real files that need adding so after I can undo the add I will use add with the exclude flag
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
查看这个善变技巧。引用链接 - 如果您不小心添加了一个文件,则撤消该文件的方法(将其状态从 A 更改回 ? 或未知)是 hg revert。例如,如果您刚刚运行 hg add 并意识到您不希望 Mercurial 跟踪文件 foo 或 bar:
Check out this mercurial tip. To cite the link - if you have accidentally added a file, the way to undo that (changing its status from A back to ?, or unknown) is hg revert. For example, if you just ran hg add and realized that you do not want files foo or bar to be tracked by Mercurial:
revert
或remove
可用于取消添加尚未提交的内容。然而,它们也都有其他用途,因此为了清楚起见,在 1.3 中(重新)添加了hgforget
,尽管它的名称如此,但它可能更容易记住。Either
revert
orremove
can be used to un-add not yet commited stuff. However, they both have other uses too, so for clarityhg forget
was (re-)added in 1.3, and despite its name it might be easier to remember.如果您使用的是类 Unix 系统,我相信最好的选择是运行
hg status -an0 | xargs -0 hg 恢复
If you are using a Unix like system i believe the best option is to run
hg status -an0 | xargs -0 hg revert
针对此类情况的两个提示:
Two tips for these sorts of situations: