简体   繁体   English

如何取消更改,但继续跟踪Mercurial中的文件?

[英]How to unstage changes but keep tracking a file in Mercurial?

For example, I have 2 files: A and B 例如,我有2个文件: AB

Both of them are tracked and modified then. 然后跟踪和修改它们。 What I want to do is to commit one file at one time. 我想要做的是一次提交一个文件。

In git, I can do it like this: 在git中,我可以这样做:

git add A
git commit -m "add A"
git add B
git commit -m "add B"

But in Mercurial, I don't know how to do the same thing. 但在Mercurial,我不知道如何做同样的事情。 Because in the first commit, the changes of B will also be commit automatically. 因为在第一次提交时,B的更改也将自动提交。 Does anyone have ideas about this? 有没有人有这个想法?

You have to read hg help commit carefully : 你必须仔细阅读hg help commit

hg commit [OPTION]... [FILE]...

aliases: ci

commit the specified files or all outstanding changes

ie if you add filename(s), Mercurial commit only specified changed files, without filenamemes - all 即如果你添加文件名,Mercurial 提交指定已更改的文件,没有filenamemes - all

hg ci -m "Add a" A & hg ci -m "Add B" B will produce two changesets (for the cost of 2 commands instead of 4, BTW) hg ci -m "Add a" A & hg ci -m "Add B" B将产生两个变更集(代价为2个命令,而不是4个,BTW)

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

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