Mercurial > hg-website
Help: rewind
hg rewind [--as-divergence] [--exact] [--keep] [--to REV]... [--from REV]...
aliases: undo
rewind a stack of changesets to a previous state
This command can be used to restore stacks of changesets to an obsolete state, creating identical copies.
There are two main ways to select the rewind target. Rewinding "from" changesets will restore the direct predecessors of these changesets (and obsolete the changeset you rewind from). Rewinding "to" will restore the changeset you have selected (and obsolete their latest successors).
By default, we rewind from the working directory parents, restoring its predecessor.
When we rewind to an obsolete version, we also rewind to all its obsolete ancestors. To only rewind to the explicitly selected changesets use the '--exact' flag. Using the '--exact' flag can restore some changesets as orphan.
The latest successors of the obsolete changesets will be superseded by these new copies. This behavior can be disabled using '--as-divergence', the current latest successors won't be affected and content-divergence will appear between them and the restored version of the obsolete changesets.
Current rough edges:
- fold: rewinding to only some of the initially folded changesets will be problematic. The fold result is marked obsolete and the part not rewinded to are "lost". Please use --as-divergence when you need to perform such operation.
- 'hg rewind' might affect changesets outside the current stack. Without --exact, we also restore ancestors of the rewind target, obsoleting their latest successors (unless --as-divergent is provided). In some case, these latest successors will be on branches unrelated to the changeset you rewind from. (We plan to automatically detect this case in the future)
options ([+] can be repeated):
--to REV [+] | rewind to these revisions | |
--as-divergence | preserve current latest successors | |
--exact | only rewind explicitly selected revisions | |
--from REV [+] | rewind these revisions to their predecessors | |
-k | --keep | do not modify working directory during rewind |
-n | --dry-run | do not perform actions, just print what would be done |
global options ([+] can be repeated):
-R | --repository REPO | repository root directory or name of overlay bundle file |
--cwd DIR | change working directory | |
-y | --noninteractive | do not prompt, automatically pick the first choice for all prompts |
-q | --quiet | suppress output |
-v | --verbose | enable additional output |
--color TYPE | when to colorize (boolean, always, auto, never, or debug) | |
--config CONFIG [+] | set/override config option (use 'section.name=value') | |
--debug | enable debugging output | |
--debugger | start debugger | |
--encoding ENCODE | set the charset encoding (default: UTF-8) | |
--encodingmode MODE | set the charset encoding mode (default: strict) | |
--traceback | always print a traceback on exception | |
--time | time how long the command takes | |
--profile | print command execution profile | |
--version | output version information and exit | |
-h | --help | display help and exit |
--hidden | consider hidden changesets | |
--pager TYPE | when to paginate (boolean, always, auto, or never) (default: auto) |