LinuxCommandLibrary

hg-push

Push Mercurial commits to a remote repository

TLDR

Push changes to the "default" remote path

$ hg push
copy

Push changes to a specified remote repository
$ hg push [path/to/destination_repository]
copy

Push a new branch if it does not exist (disabled by default)
$ hg push --new-branch
copy

Specify a specific revision changeset to push
$ hg push [[-r|--rev]] [revision]
copy

Specify a specific branch to push
$ hg push [[-b|--branch]] [branch]
copy

Specify a specific bookmark to push
$ hg push [[-B|--bookmark]] [bookmark]
copy

SYNOPSIS

hg push [-f] [-r REV]... [-b BRANCH] [-B BUNDLE] [--new-branch] [-e CMD] [--remotecmd CMD] [DEST]

PARAMETERS

-f, --force
    Force push, overriding remote restrictions like multiple heads

-r REV, --rev REV
    Push only specified revisions (multiple allowed)

-b BRANCH, --branch BRANCH
    Push only changesets in specified branches (multiple allowed)

-B BUNDLE, --bundle BUNDLEFILE
    Bundle changesets into file and push (requires filesystem access)

--new-branch
    Allow pushing new remote branches

-e CMD, --ssh CMD
    Specify command for SSH connections (default: ssh)

--remotecmd CMD
    Specify hg command to run on remote (default: hg)

--insecure
    Skip HTTPS server certificate verification

-C, --continue
    Resume interrupted bundle push

--no-continue
    Abort instead of resuming interrupted push

--peer
    Operate in peer-to-peer mode (experimental)

DESCRIPTION

The hg push command uploads outgoing changesets from the local repository to a specified destination repository, typically a remote server.

By default, it identifies and pushes all new changesets reachable from local heads that are unknown to the destination. This ensures synchronization without overwriting remote history.

It refuses to push new named branches unless --new-branch is used, preventing accidental branch proliferation. For selective pushes, use -r REV or -b BRANCH. If the push would create multiple heads on the destination, it aborts unless --force is specified.

Supports SSH, HTTP/HTTPS, and local destinations. Bundled pushes via -B create an offline bundle for later transmission. Interrupts can be resumed with --continue.

Common use: hg push after commits to share changes with team members.

CAVEATS

Refuses new branches by default; aborts on multiple destination heads without -f. Slow over slow networks for large repos. Not atomic; partial failures possible.

DEFAULT DESTINATION

Uses hgrc [paths] default-push or default if DEST omitted.
Example: hg push origin

EXIT CODES

0: success
1: aborted
2: error
3: interrupted

HISTORY

Introduced in Mercurial 0.9b (2006). Evolved with bundling in 1.0 (2008), new-branch safety in 1.1. Key for distributed workflows; refined for security/performance in modern versions.

SEE ALSO

hg(1), hg pull(1), hg outgoing(1), hg incoming(1)

Copied to clipboard