LinuxCommandLibrary

dolt-add

Stage changes for the next Dolt commit

TLDR

Add a table to the list of staged tables (stage a table)

$ dolt add [table]
copy

Stage all tables
$ dolt add [[-A|--all]]
copy

SYNOPSIS

dolt add [options] [paths…]

PARAMETERS

-A, --all
    Stage all changes in working tableset, including deletions.

-j, --num-threads <THREADS>
    Set number of threads for parallel processing (default: 1).

--schema
    Stage schema modifications only.

--stats
    Display statistics on staged changes after completion.

-v, --verbose
    Enable verbose output during staging.

DESCRIPTION

The dolt add command is part of the Dolt database system, which provides Git-like version control for SQL databases. Similar to git add, it stages changes from the working tableset to the index (staging area) in preparation for a dolt commit.

Dolt tracks both data and schema changes across tables. Running dolt add without arguments stages all modified tables. You can specify particular tables to stage only those changes, enabling selective commits.

When executed, it computes diffs between the working set and staged set, adding insertions, deletions, and updates to the index. Schema alterations, like adding columns, can be staged separately with --schema. This granular control supports complex workflows, such as branching database histories or collaborative development.

Output includes progress for large datasets, with options for verbosity and multi-threading to optimize performance. Stats mode shows added row counts post-operation.

Ideal for data engineers versioning datasets, dolt add ensures only intended changes are committed, maintaining clean history in Dolt repositories.

CAVEATS

Dolt must be initialized in the current directory with dolt init. Only tracks tables; non-table files use standard Git. Large tables may consume significant memory during staging.

EXAMPLES

dolt add table1.sql
Stage changes to specific table.

dolt add -A
Stage everything.

dolt add --schema --stats
Stage and report schema changes.

EXIT STATUS

0 on success, non-zero on errors like invalid tables or conflicts.

HISTORY

Dolt introduced in 2019 by DoltHub (now part of PlanetScale). dolt add debuted in early versions to mirror Git semantics, evolving with multi-threaded support in v1.0+ for better performance on massive datasets.

SEE ALSO

dolt-status(1), dolt-commit(1), dolt-diff(1), git-add(1)

Copied to clipboard