Hanfei Sun
Hanfei Sun

Reputation: 47051

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?

Upvotes: 1

Views: 898

Answers (1)

Lazy Badger
Lazy Badger

Reputation: 97282

You have to read hg help commit carefully:

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

aliases: ci

commit the specified files or all outstanding changes

i.e 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)

Upvotes: 4

Related Questions