Mercurial cherry picking changes for commit

If you are using TortoiseHg 1.x for Windows, this feature is implemented beautifully right out of the box (no extensions required).

  1. Run the TortoiseHg Commit Tool.
  2. Choose a file for which you only want to commit a subset of its changes.
  3. Click on the Hunk Selection tab in the preview pane.
  4. Double-click or use the spacebar to toggle which change hunks should be included in the commit.

For TortoiseHg 2.x, the Hunk Selection tab is now gone. In its place, is the Shelve tool. It has a few more features than the old hunk selection. Those new features come at the cost of some added complexity.

enter image description here

Note that there is no need to explicitly enable the Mercurial Shelve extension when using this feature. According to Steve Borho (lead TortoiseHg developer) in response to a different TortoiseHg question: "We have a local copy of the shelve extension and call into it directly."


For TortoiseHg 2.7+, this functionality has been improved and re-introduced. It is now built directly into the Commit tool:

example of change selection in the commit tool

Notice in the file list on the left that the top file is checked to indicate it will be included, the second file is unchecked because it will not be included, and the third file, Sample.txt, is filled (the Null checkbox indicator) because only select changes from that file will be included in the commit.

The change to Sample.txt that will be included is checked in the lower-right change selection portion of the image. The change that will be excluded is unchecked and the diff view is grayed out. Also notice that the icon for the shelve tool is still readily available.


MQ as Chad mentioned are one way. There's also more lightweight solutions:

  • Record extension which works roughly the same way as darcs record. It's distributed with mercurial.
  • Shelve extension which allows you to "shelve" certain changes, allowing you to commit only a subset of your changes (the ones that are not shelved)