OverviewTeaching: 10 min
Exercises: 5 minQuestions
How do I get set up to use Mercurial?Objectives
Explain what configuration steps are required the first time Mercurial is used on a computer.
When we use Mercurial on a computer for the first time, we need to configure a few things. The command
$ hg config --edit
should open a template Mercurial configuration file in an editor for you.
On Windows the file will likely appear in
On OS X and Linux,
EDITOR environment variable is not set to something else,
the file will likely appear in
If that doesn’t make you happy,
prefix the command with
nano is a nice,
safe choice if you don’t know what else to choose:
$ EDITOR=nano hg config --edit
The file should look a lot like:
# example user config (see "hg help config" for more info) [ui] # name and email, e.g. # username = Jane Doe <email@example.com> username = [extensions] # uncomment these lines to enable some popular extensions # (see "hg help extensions" for more info) # # pager = # progress = # color =
Edit the file to set
username to your own name and email address and add your
favourite editor in the
Also uncomment the
color = lines in the
You can leave or delete the other comment lines (that start with
#) as you wish.
When you are done your file should look something like:
[ui] username = Doug Latornell <firstname.lastname@example.org> editor = nano [extensions] pager = progress = color =
If you are on Windows,
please also add a
[color] section to the file:
[color] mode = win32
When you are finished, save the file and exit your editor.
hg: unknown command ‘config’
If your computer responds to the
hg config --editcommand with
hg: unknown command 'config'
it means that you are using a version of Mercurial older than 3.0 that doesn’t have the
You will have to create your configuration file from scratch. Windows users can use:
to create the file, and Mac OS X and Linux users can use:
to create the appropriately named empty file and then type in the lines above.
When you saved the file it was stored in your home directory as
.hgrc on OS X and
Linux or as
Mercurial.ini on Windows.
The fact that these settings are in the Mercurial configuration file in our home
directory means that they will be used for every Mercurial repository on this
The above configuration work only needs to be done the first time you use Mercurial on a computer.
You can check that your settings are the way that you want them with the command
$ hg config ui extensions
extensions.color= extensions.progress= extensions.pager= ui.username=Doug Latornell <email@example.com>
hg configto configure a user name, email address, editor, and other preferences once per machine.