Mercurial

Creating a repository

To turn a folder into a repository:

$hg init

Adding files to the tracking:

$hg add <filename>

If no filename is provided all files are added

Removing a file from tracking:

$hg forget <filename>

To commit your changes:

$hg commit -m <Commit message|Version number>

To push your fork back into the main repository:

$hg push <destination>

If your hg destination is empty it will default to the one specified in the hgrc file.

The hgrc file should be inside the repository, in the .hg folder, and should cotain the lines:

[paths]
default=<url|path>
default-push=<url|path>

Another hgrc file should be inside the home folder and should cotain the lines:

[ui]
username = <username> <email>
[extensions]
strip =

The strip extension is used to remove changesets from the history and delete their files. Use like this:

$hg strip <branch|changeset hash>

To branch a repository:

$hg branch <branch name>

To navigate between the changesets, first list them:

$hg history

Then see where you are in it:

$hg summary

If you want some visual aid do:

$hg serve

And to change the state of the repository to the desired changeset by doing:

$hg update <branch|changeset number>

If left blank, will update to the tip of the repository.

To merge branches first update into the receiving branch, then:

$hg merge <branch>

If conflicts happen, they can be solved by manually marking as solved:

$nano <file>
$hg resolve -m <file>

Or they can be marked for replacement by:

$hg resolve -t internal:local <file>
$hg resolve -t internal:other <file>

Where local means the updated into branch and other is the one being merged to it, so the first option keeps the file while the second overwrites it.