Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial Unstage Specific Files from Working Directory

Tags:

mercurial

I have an uncommitted changeset. I want to commit some of the changes, but not commit some of the files (like unstaging a file in git). Can this be done in mercurial?

like image 400
Joda Maki Avatar asked Mar 29 '11 17:03

Joda Maki


People also ask

How do you Unstage a file while retaining the changes in working directory?

To unstage commits on Git, use the “git reset” command with the “–soft” option and specify the commit hash. Alternatively, if you want to unstage your last commit, you can the “HEAD” notation in order to revert it easily. Using the “–soft” argument, changes are kept in your working directory and index.

How do I remove untracked files from Mercurial?

Add the Mercurial Extension called purge. It is distributed by Mercurial. It is not enabled by default, maybe to avoid accidentally removing files that you forgot to add. Save this answer.

How do I revert a file in Mercurial?

To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.


1 Answers

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
like image 68
Niall C. Avatar answered Sep 28 '22 08:09

Niall C.