hg-push
Push Mercurial commits to a remote repository
TLDR
Push changes to the "default" remote path
Push changes to a specified remote repository
Push a new branch if it does not exist (disabled by default)
Specify a specific revision changeset to push
Specify a specific branch to push
Specify a specific bookmark to push
SYNOPSIS
hg push [-r REV]... [-b BRANCH]... [-f] [-e CMD] [--remotecmd CMD] [DEST]
PARAMETERS
-r REV
Push only revisions specified by REV (revision, tag, or branch name). Can be used multiple times.
-b BRANCH
Push all changesets on the specified branch. Can be used multiple times.
-f
Force push. This will allow pushing even if it creates new heads on the remote repository. Use with caution, as it can disrupt the remote repository's history.
-e CMD, --ssh CMD
Specify command used to connect to remote SSH Mercurial repositories.
--remotecmd CMD
Specify command to execute on the remote side.
DEST
The URL or local path of the destination repository. If omitted, uses the default push target defined in the repository configuration.
DESCRIPTION
The `hg push` command in Mercurial (hg) is used to transmit sets of changes from your local repository to another repository. This enables collaboration by sharing your work with others and keeping remote repositories up-to-date. By default, `hg push` will push all new changesets from your current branch. You can specify a particular revision, tag, or branch to push only those specific changesets. Mercurial tracks branches separately, so pushing to a different branch is possible.
The command requires network access to the remote repository. It interacts with the remote repository over HTTP, SSH, or other configured transports. If a remote repository requires authentication, you may need to configure credentials in your Mercurial configuration file. If conflicts arise during the push, Mercurial will attempt to resolve them automatically, but you may need to manually resolve conflicts if they are too complex. The remote repository must also allow pushing operations (it may be configured to only allow pulling).
CAVEATS
Force pushing (`-f`) can cause disruption and lost changesets on the remote repository if not used carefully. Ensure you understand the consequences before using this option. Verify remote repository configuration if facing issues with pushing.
CONFIGURATION
The behavior of `hg push` can be configured in the `.hgrc` file (Mercurial configuration file). Settings such as the default push target, SSH command, and authentication details can be specified globally or on a per-repository basis.
Example .hgrc:
[paths]
default = ssh://hg@example.com/repo
[auth]
example.prefix = ssh://hg@example.com/repo
example.username = myusername
example.password = mypassword
PUSHING TO A SPECIFIC BRANCH
To push a specific branch, use the `-b` option followed by the branch name. For example, `hg push -b develop` will push all changesets on the 'develop' branch to the remote repository.
HISTORY
The `hg push` command is a core component of Mercurial's distributed version control system, designed from the beginning to enable collaborative development across multiple repositories. It has been part of Mercurial since its early releases and has been refined over time with new features and optimizations. Originally designed to be easy to use for mirroring repositories or replicating new changes, its evolution has also reflected the growing needs of teams working on large and complex projects. The `hg push` command is integral to the distributed workflow.
SEE ALSO
hg pull(1), hg clone(1), hg update(1), hg commit(1)