Mercurial for Beginners: The Definitive Practical Guide


Inspired by Git for beginners: The definitive practical guide.

This is a compilation of information on using Mercurial for beginners for practical use.

Beginner – a programmer who has touched source control without understanding it very well.

Practical – covering situations that the majority of users often encounter – creating a repository, branching, merging, pulling/pushing from/to a remote repository, etc.


  • Explain how to get something done rather than how something is
  • Deal with one question per answer.
  • Answer clearly and as concisely as possible.
  • Edit/extend an existing answer rather than create a new answer on the
    same topic.
  • Please provide a link to the the Mercurial wiki or the HG Book for people who want to learn more.



Working with the code

Tagging, branching, releases, baselines


Other Mercurial references

Best Solution

How do you configure it to ignore files?

Ignore is configured in a normal text file called .hgignore in the root of your repository. Add it just like a normal file with:

hg add .hgignore

There are two syntax options available for file matching, glob and regexp. glob is unix-like filename expansion and regexp is regular expressions. You activate each by adding syntax: glob or syntax: regexp on a line by itself. All lines following that will use that syntax, until the next syntax marker. You can have as many syntax markers as you want. The default syntax is regexp, so if you only use regexp you don't need any syntax marker.

You can add comments with #


# python temporary files
syntax: glob

#editor autosaves

# temporary data
syntax: regexp

Ignore only applies to unmanaged files (i.e. files that are not already checked in). To ignore files that are under version control, you can use the switches -I and -X.