Skip to content Skip to main navigation Skip to footer

Mercurial Cheatsheet

Configuration

Configure global information

# This command launches default editor
# Set "username" in [UI] section:
#     username = Mercury Gitlab <mercury.gitlab@build-masters.com>
$ hg config --edit

Initializing

Create a new local repository

hg init

#
$ mkdir hello-world
$ cd hello-world
# Init repository
$ hg init
# Simple example: add a file and commit changes
$ echo "Hello World" > README.md
$ hg add README.md
$ hg commit -m "Initial commit"

Cloning an Existing Repository

hg clone remote-repo [local-directory]

$ hg clone http://www.selenic.com/repo/hello my-hello

real URL is https://selenic.com/repo/hello
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
new changesets 0a04b987be5a:82e55d328c8c
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

Day-to-day activities

Show the working tree status

hg status

$ hg status
M hello.c
A README.md

Added, Clean, De­leted, Ig­nored, Mo­dified or ?Un­known