Github

Mercurial (hg): Distributed Version Control

Overview
Mercurial is a distributed version control system (DVCS), released in 2005 (the same year as Git). Like Git, it allows every developer to have a full copy of the repository history.

Git vs Mercurial

Philosophy
- Git: "Plumbing before Porcelain." Exposes the internal DAG. Powerful, but complex (staging area, detached HEADs).
- Mercurial: "It just works." Focuses on simplicity and preserving history. The commands (`hg commit`, `hg push`) act intuitively.

Key Differences
1. Safety: Mercurial makes it hard to overwrite history (no `force push` by default). It uses "Phases" (Draft, Public) to prevent accidents.
2. Branching:
- Git: Branches are cheap pointers.
- Mercurial: Historically used "Named Branches" (permanent). Modern Hg uses "Bookmarks" (like Git branches).
3. Staging: Mercurial commits all changed files by default. Git requires `git add`.

Commands

hg init
hg add file.txt
hg commit -m "Initial commit"
hg pull
hg update
hg push

Status
Git won the war (GitHub, GitLab, Bitbucket all focus on Git).
However, Mercurial is still faster and cleaner for massive monorepos. Facebook and Google use highly customized versions of Mercurial for their mega-repos.

"Git is MacGyver, Mercurial is James Bond."

Take github further

Ask the copilot about this term, or have our engineers assess it against your process.