Reference‎ > ‎

Mercurial Cheat Sheet

Mercurial is a distributed source control system.  I like it because:
  • It's very portable
    • Written in Python
    • Note that GIT, while much more popular, implements some commands as shell scripts so requires a somewhat kludgy installation on Windows.
  • Allows for completely offline development.
  • Is supported by - free open source project hosting
  • Is supported by Assembla - both free open-source hosted projects, and paid private project hosting.
These are the command you'll need to know for our class:

> hg clone

Use this command to make a local copy of another repository.  In our case the command:

hg clone aebootcamp

makes a local copy of the googlecode repository containing the samples for this class.

> hg pull

command copies changes made in the upstream repository to your local one.  Use this to get updates to files on our hosted project and make them available to you locally.

> hg update

This command updates your working copy. Even though you have the files in your local repository, the visible source files you see will not be updated to the tip of the project until you execute the update command.

> hg status

See what changes you've made to your local files - as compared to the last updated version of your repository.

> hg commit

When you make changes to your source files, they are not offically part of the repository until you commit them (this works locally - you don't even have to be connected to a network to commit your work in stages).  Good idea to do this often - whenever your project is stable.

Before you commit, you will want to set up a .hgrc file in (on Windows) \Users\USERNAME\.hgrc:

username = John Doe <>

> hg push

When you want to publish your changes back to the upstream repository.  Note that you don't have permissions to push back to  If you want to make your changes publicly available to others, you can click the Create a Clone button on googlecode to make your own hosted repository.

> hg branches

Display the
branches used in this repository.  A branch is like a different leaf node of all the files in the repository.  We use the
data branch to update the source files in /lessons/sample to be an extended example with a data model and forms.

> hg update -C data

This command changes your working copy to have the files from the data branch, instead of the default branch.

See also the Hg QuickStart.