简体   繁体   中英

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

For example, I have 2 files: A and B

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 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. Because in the first commit, the changes of B will also be commit automatically. Does anyone have ideas about this?

You have to read hg help commit carefully :

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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