Catalog / Mercurial Cheat Sheet
Mercurial Cheat Sheet
A comprehensive guide to Mercurial, covering essential commands for version control, branching, merging, and collaboration.
Basic Commands
Repository Operations
|
Create a new repository in the specified directory. If no directory is specified, it initializes one in the current directory. |
|
Clone an existing repository from a source (local or remote) to a destination. |
Working Directory Commands
|
Add the specified file(s) to the repository for tracking. |
|
Remove the specified file(s) from the repository. The files are removed from the next commit, but are still present in your working directory until you delete them. |
|
Show the status of files in the working directory (modified, added, removed, unknown, ignored). |
|
Revert the specified file(s) to the last committed version. |
Commit Operations
|
Commit the changes in the working directory with a descriptive message. |
|
Show the commit history of the repository. |
|
Show the differences between the working directory and the last committed version. |
Branching and Merging
Branch Management
|
Create a new named branch. |
|
List existing branches. |
|
Switch to a different branch. |
|
Merge changes from a specified branch into the current branch. |
|
Mark conflicts as resolved after a merge. |
|
Commit the merge after resolving conflicts. |
Named Branches vs. Bookmarks
Mercurial offers both named branches and bookmarks for managing concurrent development. Named branches are permanent and shared with other repositories, while bookmarks are local and lightweight, ideal for tracking experimental changes. |
Bookmarks
|
Create a new bookmark at the current revision. |
|
List existing bookmarks. |
|
Switch to a different bookmark. |
|
Delete a bookmark. |
Remote Repositories
Synchronization
|
Pull changes from a remote repository to the local repository. |
|
Push changes from the local repository to a remote repository. |
|
Show incoming changes from the default remote repository without applying them. |
|
Show outgoing changes to the default remote repository. |
Configuration
Remote repository URLs can be configured in the |
[paths] |
Example Workflow
A common workflow involves pulling changes, updating the working directory, making changes, committing them, and then pushing the changes back to the remote repository.
|
Advanced Features
Ignoring Files
|
Create a |
Syntax |
|
Revisions
|
Update to a specific revision number or tag. |
|
Show the differences between two revisions. |
|
Revert specific files to a specific revision. |
Shelving
|
Shelve the current changes in the working directory. |
|
Unshelve the shelved changes and apply them to the working directory. |
|
Shelve with a description. |