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]
dolt branch [branchname [start-point]]
dolt branch [--set-upstream-to | -u] upstream [branchname]
dolt branch [--track | -t] remote/branchname
dolt branch [--unset-upstream | -u] [branchname]
dolt branch [--delete | -d | --force-delete | -D] branchname...
dolt branch [--move | -m | --copy | -c] [oldbranch] newbranch

PARAMETERS

branchname
    The name of the branch to create, delete, or operate on.

start-point
    The commit, branch, or tag from which to start the new branch. Defaults to the current HEAD.

--list
    List existing branches. This is the default if no branch name is provided.

-v, -vv
    Be more verbose when listing branches, showing the last commit SHA and subject.

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

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

--delete, -d
    Delete a branch only if it has been fully merged into its upstream, or HEAD.

--force-delete, -D
    Force delete a branch, regardless of its merged status. Alias for --delete --force.

--move, -m
    Move or rename a branch.

--copy, -c
    Copy a branch.

--set-upstream-to, -u upstream
    Set the upstream branch for the current branch or the specified branch. This configures tracking.

--track, -t remote/branchname
    Create a new branch that tracks a remote branch. Equivalent to dolt checkout -b --track /.

--unset-upstream, -u
    Remove the upstream information for the current branch or the specified branch.

--force, -f
    Force the creation of a branch, even if it already exists or if it would overwrite an existing branch.

--show-current
    Show the name of the current branch.

DESCRIPTION

dolt-branch is a subcommand of dolt, a unique SQL database that natively supports Git-like version control features. It allows users to create, list, delete, and rename branches within a Dolt repository. Similar to Git, branches in Dolt represent independent lines of development, but instead of tracking changes to files, they track changes to the entire database state, including schema and data.

This command is fundamental for collaborative data management, enabling multiple users or processes to work on different versions of a database concurrently without affecting the main line of development. It facilitates experimental changes, feature development, and bug fixes on isolated database states, which can later be merged back into other branches, providing a powerful workflow for data evolution.

CAVEATS

dolt-branch is a subcommand of the dolt version control system for data and is not a standalone Linux command. It requires Dolt to be installed and initialized in a directory as a Dolt repository. Unlike traditional Git, dolt-branch manages branches of database states, including schema and data, rather than file system snapshots. Users familiar with Git's branching model will find strong conceptual similarities, but the underlying data management and potential conflicts (e.g., schema merges) are distinct and SQL-centric.

BRANCHING IN DOLT VS. GIT

While dolt-branch behaves conceptually like git-branch, it's crucial to understand the distinction in what they version. Git branches track versions of a filesystem hierarchy (files and directories). Dolt branches, conversely, track versions of a SQL database's state, including its schema (tables, columns, types) and its data (rows within tables). This allows for operations like merging different database schemas or data sets, resolving conflicts at the SQL level, and reverting database states to previous versions, all managed with the familiar branching workflow.

HISTORY

Dolt, and by extension dolt-branch, emerged from the critical need for robust version control for relational databases, a capability traditionally lacking in standard database systems. Developed by Liquidata (now DoltHub), Dolt builds upon the foundational ideas of Noms, a distributed versioned data store. dolt-branch was designed to mirror the powerful and familiar branching paradigm of Git, adapting it to the specific challenges of managing evolving database schemas and data. Its development has focused on providing a familiar user experience for developers accustomed to code version control, extending those benefits to the database layer and enabling Git-like workflows for data management.

SEE ALSO

dolt(1), dolt-checkout(1), dolt-merge(1), dolt-commit(1), git-branch(1) (conceptual similarity)

Copied to clipboard