Mercurial

Mercurial Cheatsheet #

Mercurial is a distributed version control system used for tracking changes in source code during software development. It was developed by Matt Mackall and released in 2005. Mercurial efficiently handles projects of any size and offers an easy and intuitive interface. It is designed to support multiple workflows and includes branching and merging capabilities.

Repository Management #

Command/OptionExampleDescription
hg inithg initInitialize a new Mercurial repository
hg clonehg clone https://example.com/repoClone an existing repository

Staging and Committing #

Command/OptionExampleDescription
hg addhg add file.txtAdd a file to the repository
hg commit (ci)hg commit -m "Commit message"Record changes to the repository
hg status (st)hg statusShow the status of files in the working directory
hg diffhg diffShow differences between revisions

Branching and Merging #

Command/OptionExampleDescription
hg branchhg branch new-branchCreate a new branch
hg update (up)hg update new-branchSwitch to a different branch
hg mergehg merge new-branchMerge changes from another branch
hg rebasehg rebase -s source -d destReapply changes from one branch to another

Remote Repositories #

Command/OptionExampleDescription
hg pullhg pullPull changes from a remote repository
hg pushhg pushPush changes to a remote repository
hg pathshg pathsShow aliases for remote repositories

Undoing Changes #

Command/OptionExampleDescription
hg reverthg revert file.txtRevert a file to its previous state
hg remove (rm)hg remove file.txtRemove a file from the repository
hg rollbackhg rollbackRoll back the last transaction in the repository

Viewing History and Logs #

Command/OptionExampleDescription
hg loghg logShow commit logs
hg annotatehg annotate file.txtShow changeset information by line for each file
hg summaryhg summaryShow a summary of the working directory state

Tags and Bookmarks #

Command/OptionExampleDescription
hg taghg tag v1.0Add a tag for the current changeset
hg tagshg tagsList tags
hg bookmarkhg bookmark new-featureCreate a bookmark at the current changeset
hg bookmarkshg bookmarksList bookmarks

Repository Maintenance #

Command/OptionExampleDescription
hg verifyhg verifyVerify the integrity of the repository
hg cleanhg cleanRemove unknown files from the working directory
hg bundlehg bundle repo.hgCreate a bundle containing changesets

Miscellaneous #

Command/OptionExampleDescription
hg helphg helpShow help for commands
hg confighg configShow combined global and per-repository configurations
hg servehg serveStart a web server for the repository
hg archivehg archive -r rev destinationCreate an unversioned archive of a repository

This cheatsheet covers the most commonly used Mercurial commands and options, helping you to manage repositories, commits, branches, merges, and more effectively.

Mercurial

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.