Show Menu
Cheatography

Mercurial (Hg) Cheat Sheet by

Cheat Sheet for the Mercurial distributed source version control management tool. System.http://mercurial.selenic.com/

Hg - Work Directory

A local Work folder containing one Revision and any uncommited changes you've made.

Hg - Undos and Fixes

hg rollback can undo commit, import, pull, local push, and unbundle. Only use in private repos.
hg update --clean can cancel an uncomm­itted merge while losing changes.

Hg - Create an Archive

hg archive -rREV filena­me.zip
hg archive -rREV filena­me.t­ar.gz

Hg - Work Files and Tracking

hg add file
Begin tracking changes
hg addremove
Track new, forget missing
hg forget file
Stop tracking file
hg remove file
Stop tracking & del
hg copy file target
Copy file
hg move file target
Move file
These changes to Work must also be Committed to avoid data loss.

Hg - Work Directory Updates

hg update tip
Update Work to match Tip
hg update -rREV
Update Work to specified Revision
hg revert
Undo all uncomm­itted changes

Hg - Work Status

hg diff
Lists tracked file changes
hg diff file
List changes to a file
hg status
Lists status of files
Added, Clean, Deleted,
Ignored, Modified, Unknown
 

Hg - Local Repository

A complete Local repository of changesets that is saved in Work/.hg/ (don't edit!)

Hg - Local Repo History

hg log file/dir
History of changesets
hg annotate file
Who changed what, when
hg paths
Lists known remote Repos
hg heads
List heads
hg diff -rREV -rREV
Shows differ­ences between REVs

Hg - Create a Local Repo

hg init Work
Creates ./.hg/ subfolder & Repo
hg add
Begin tracking all files
hg commit -m 'Initial commit'
Save files and Commit message to Repo

Hg - Clone Remote Repo

hg clone Remote Work

Hg - Update from Remote Repo

hg incoming Remote
List changesets available
hg pull
Pull all new changesets into Local
hg pull -r Remote
Pull specified changesets into Local
-u
Also Update Working Directory

Hg - Union Merge

hg pull --force unrela­ted­_pr­oject
hg merge
hg commit
Powerful simpli­city! Use wisely.

Hg - Resources

 

Hg - Remote Repository

A Remote repository reached via url path, often a main team repo from which Local is cloned.

Hg - Remote Update and Publish

hg push Remote
Push changesets to Remote
hg share
Sync history with parent and siblings

Hg - Termin­ology

Repository
Repo. Collection of Revisions.
Revision
Rev. Commited changeset, by REV number.
Changeset
Set of Work changes saved as Diffs.
Diff
Changes between files.
Tag
Name for a specific Rev.
Parent
Immediate ancestor of Rev or Work.
Branch
Child of Rev.
Merge
Rev with two parents.
Head
Latest Rev in Branch.
Tip
Latest Rev in ANY Branch.
Patch
All Diffs between two Revs.
Bundle
Patch with permis­sions and rename support.

Hg - Help

hg
Basic command list.
hg help
Full command list.
hg help command
Detailed help reference.

Hg - Command Line

hg command -option... argume­nt...
required non-li­teral reference

Hg - Common Options

-rREV
Specify a Rev number (default parent.)
-y
Don't prompt; pick each first option.
-q
Quiet (supress output.)
-v
Verbose (addit­ional detail)
-f
Force (override reasonable warnings.)
                               
 

Comments

Wow! Great cheat sheet! :)

codeshane codeshane, 09:48 15 Aug 12

Thanks. Plenty of room for improvement, but getting started is the hardest part. :D

Does "hg share" require an extension? Running "hg help share" gets me the "unknown command" error.

Sorry for the late reply, wasn't expecting a Q&A here .. the "share" extension is included with Hg, but disabled by default. The link below explainshow to set it up, hope it helps! http://mercurial.selenic.com/wiki/ShareExtension

Can't start download. http://www.cheatography.com/codeshane/cheat-sheets/mercurial-hg/pdf/ is referring back to http://www.cheatography.com/codeshane/cheat-sheets/mercurial-hg/ :(

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Subversion Cheat Sheet
          VI Editor Cheat Sheet
          Bazaar version control system Cheat Sheet