hg Verified current stable Not installed? Version Control

Hg / Create New Branch For Next Commit

Create New Branch For Next Commit

Use the hg branch command to create a new branch for your next commits in Mercurial.

$
Terminal
hg branch <branch_name>

When To Use

Creating a new branch to isolate feature development from the main line.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
hg branch <branch_name>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
$ hg branch feature-xyz
$ hg commit -m "Start working on feature xyz"

Power User Variants

Optimized versions

hg branch feature-abc

Create a branch named feature-abc.

hg branch bugfix-123

Create a branch for bugfix-123.

Unix Pipeline

Shell combinations

hg branch new-feature && hg commit -m "Initial commit on new-feature"

Create a new branch and commit changes in one line.

Troubleshooting

Common pitfalls

Branch name already exists

Solution: Choose a different branch name.

No changes to commit

Solution: Make changes before committing.

Command Breakdown

What each part is doing

hg
Base Command
The executable that performs this operation. Here it runs Hg before the shell applies any redirect operators.
<branch_name>
branch name
The value supplied for branch name.

How To Run

Execution path

  1. Step 1

    Run the command `hg branch {{branch_name}}` to create a new branch.

  2. Step 2

    Make your changes and stage them as needed.

  3. Step 3

    Commit your changes to the new branch.

Alternative Approaches

Comparable commands in other tools

Alternative version control tools for the same job.