Search code examples
gitmercurialgit-add

hg equivalent of git add -p?


Is there a mercurial equivalent of git add -p?

Quoting from man, git-add with the option -p (or --patch) does the following:

Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index.


Solution

  • Have a look at the record extension (which comes bundled with Mercurial).

    Note that since Mercurial doesn't have the concept of the staging area like git, running hg record will simply allow you to examine, hunk by hunk, the modifications in your working copy. Any changes you choose to record will be committed, and any changes you choose not to record are simply left as modifications in your working copy.