LinuxCommandLibrary

dolt-branch

Manage Dolt database branches

TLDR

List local branches (current branch is highlighted by *)

$ dolt branch
copy

List all local and remote branches
$ dolt branch [[-A|--all]]
copy

Create a new branch based on the current branch
$ dolt branch [branch_name]
copy

Create a new branch with the specified commit as the latest
$ dolt branch [branch_name] [commit]
copy

Rename a branch
$ dolt branch [[-m|--move]] [branch_name1] [branch_name2]
copy

Duplicate a branch
$ dolt branch [[-c|--copy]] [branch_name1] [branch_name2]
copy

Delete a branch
$ dolt branch [[-d|--delete]] [branch_name]
copy

Display the name of the current branch
$ dolt branch --show-current
copy

SYNOPSIS

dolt branch [options...] [new-branch] [start-point]

PARAMETERS

-a, --all
    List both remote-tracking and local branches

-d, --delete
    Delete specified branch (must be merged)

-D
    Force delete branch even if not fully merged

-f, --force
    Force create or reset branch to start-point

-l, --list
    List branches (default behavior)

-m, --move
    Rename or move a branch

-M
    Force rename branch even if target exists

-q, --quiet
    Suppress output when creating/deleting

-r, --remotes
    List remote-tracking branches only

-v, --verbose
    Show commit hashes with branch names

--merged [commit]
    List branches merged into commit (HEAD default)

--no-merged [commit]
    List branches not merged into commit

--track
    Set up branch tracking with remote counterpart

-h, --help
    Show help and exit

DESCRIPTION

The dolt branch command is part of the Dolt toolkit, a MySQL-compatible SQL database with Git-like version control for data. It allows users to list, create, rename, and delete branches in a Dolt repository, enabling parallel development of database schemas and data.

Branches in Dolt represent snapshots of the database at different points, similar to Git. Listing branches shows local branches with an asterisk (*) marking the current one. Creating a new branch with dolt branch new-branch starts it from the current HEAD. Options support verbose output, remote branches, merged status checks, and force operations.

This command is essential for collaborative workflows, feature development, and versioning datasets without overwriting main branches. It integrates with other Dolt commands like checkout and merge for full version control.

CAVEATS

Must be run inside a Dolt repository directory. Deleting unmerged branches with -D risks data loss. Remote operations require dolt fetch first.

EXAMPLES

dolt branch # List branches
dolt branch feature-xyz # Create from HEAD
dolt branch -d old-branch # Delete merged branch

EXIT STATUS

0 on success, non-zero on error (e.g., invalid branch name)

HISTORY

Dolt branch introduced in Dolt v0.1.0 (2019) by Liquidata (now DoltHub). Evolved to near Git compatibility by v1.0 (2022), adding remote tracking and reflog support.

SEE ALSO

dolt-checkout(1), dolt-merge(1), dolt-log(1), git-branch(1)

Copied to clipboard