shelve

Description

The "hg shelve" command saves changes made to the working directory and reverts those changes, resetting the working directory to a clean state.

Later on, the "hg unshelve" command restores the changes saved by "hg shelve". Changes can be restored even after updating to a different parent, in which case Mercurial's merge machinery will resolve any conflicts if necessary.

You can have more than one shelved change outstanding at a time; each shelved change has a distinct name. For details, see the help for "hg shelve".

Commands

shelve

save and set aside changes from the working directory:

hg shelve [OPTION]... [FILE]...

Shelving takes files that "hg status" reports as not clean, saves the modifications to a bundle (a shelved change), and reverts the files so that their state in the working directory becomes clean.

To restore these changes to the working directory, using "hg unshelve"; this will work even if you switch to a different commit.

When no files are specified, "hg shelve" saves all not-clean files. If specific files or directories are named, only changes to those files are shelved.

In bare shelve (when no files are specified, without interactive, include and exclude option), shelving remembers information if the working directory was on newly created branch, in other words working directory was on different branch than its first parent. In this situation unshelving restores branch information to the working directory.

Each shelved change has a name that makes it easier to find later. The name of a shelved change defaults to being based on the active bookmark, or if there is no active bookmark, the current named branch. To specify a different name, use --name.

To see a list of existing shelved changes, use the --list option. For each shelved change, this will print its name, age, and description; use --patch or --stat for more details.

To delete specific shelved changes, use --delete. To delete all shelved changes, use --cleanup.

Options:

-A, --addremove
 mark new/missing files as added/removed before shelving
-u, --unknown store unknown files in the shelve
--cleanup delete all shelved changes
--date <DATE> shelve with the specified commit date
-d, --delete delete the named shelved change(s)
-e, --edit invoke editor on commit messages
-l, --list list current shelves
-m, --message <TEXT>
 use text as shelve message
-n, --name <NAME>
 use the given name for the shelved commit
-p, --patch output patches for changes (provide the names of the shelved changes as positional arguments)
-i, --interactive
 interactive mode, only works while creating a shelve
--stat output diffstat-style summary of changes (provide the names of the shelved changes as positional arguments)
-I, --include <PATTERN[+]>
 include names matching the given patterns
-X, --exclude <PATTERN[+]>
 exclude names matching the given patterns

[+] marked option can be specified multiple times

unshelve

restore a shelved change to the working directory:

hg unshelve [[-n] SHELVED]

This command accepts an optional name of a shelved change to restore. If none is given, the most recent shelved change is used.

If a shelved change is applied successfully, the bundle that contains the shelved changes is moved to a backup location (.hg/shelve-backup).

Since you can restore a shelved change on top of an arbitrary commit, it is possible that unshelving will result in a conflict between your changes and the commits you are unshelving onto. If this occurs, you must resolve the conflict, then use --continue to complete the unshelve operation. (The bundle will not be moved until you successfully complete the unshelve.)

(Alternatively, you can use --abort to abandon an unshelve that causes a conflict. This reverts the unshelved changes, and leaves the bundle in place.)

If bare shelved change(when no files are specified, without interactive, include and exclude option) was done on newly created branch it would restore branch information to the working directory.

After a successful unshelve, the shelved changes are stored in a backup directory. Only the N most recent backups are kept. N defaults to 10 but can be overridden using the shelve.maxbackups configuration option.

Timestamp in seconds is used to decide order of backups. More than maxbackups backups are kept, if same timestamp prevents from deciding exact order of them, for safety.

Options:

-a, --abort abort an incomplete unshelve operation
-c, --continue continue an incomplete unshelve operation
-k, --keep keep shelve after unshelving
-n, --name <NAME>
 restore shelved change with given name
-t, --tool <VALUE>
 specify merge tool
--date <DATE> set date for temporary commits (DEPRECATED)