Mercurial Unstage Specific Files from Working Directory
I have an uncommitted changeset. I want to commit some of the changes, but not commit some of the files (like un开发者_如何学Cstaging a file in git). Can this be done in mercurial?
Use the -X
option to hg commit
to exclude certain files. You can specify it more than once on the command line. For example,
hg commit -X path/to/unwanted/file -X path/to/another/file
You can pass a list of files to commit to hg commit
, e.g. hg commit -m msg file1 file2 ...
.
Yep! You have two options.
Commit just some files.
If you provide file names as arguments to
hg commit
, only those files will be committed. So if I have the followinghg status
:M foo.txt M bar.txt
I can run
hg commit foo.txt
to commit just the changes tofoo.txt
and leave the changes inbar.txt
for a later commit.Use the
record
extension.The Record extension gives Mercurial behavior to git's index, letting you commit just some patches of your changes (like
git add --patch
). See the docs for more info.
精彩评论