QRdvark.com

Introduction To Mecurial

Introduction To Mecurial

This tutorial is for those moving from SVN or CVS to Mecurial. It covers most of the basic commands you will need to get started with mecurial versioning system.

There's been some questions about mercurial branches Below is a short list of scenarios approximating the workflow we're looking at with mercurial. It's important to note that when you do a commit, the commit text indicates which branch the change is for. Make sure you're aware of what branch you're committing too.

When you're in a branch, you can (and should) commit and push to the central repo. You don't need to keep all your changes local until you've finished.

Add a file
hg add file.php
Commit a file
hg commit -m 'Added file.php' (only commits locally)
Commit a file to repo
hg push (after hg commit)
Get upstream changes
hg pull
hg merge
Developer creates a new branch
hg branch new-feature
hg commit
hg push
Developer switches to new branch
hg up new-feature
Developer does work on new branch
hg commit
hg push
Developer needs to do work on trunk (called "default" in mercurial)
hg up default
hg commit
hg push
hg up new-feature
Developer completes work on a branch
hg up default
hg merge new-feature
hg commit
hg push
Developer abandons a branch (task cancelled)
hg commit --close-branch
hg up default

Useful Tips

Resolve .hgtags
hg resolve -m .hgtags