dolt-add
Stage changes for the next Dolt commit
TLDR
Add a table to the list of staged tables (stage a table)
Stage all tables
SYNOPSIS
dolt add [options] pathspec...
dolt add [options] --all
PARAMETERS
pathspec...
Specifies one or more table names or path specifications to stage. Only changes to these tables will be added to the staging area.
--all, -A
Stages all changes in the working directory, including new tables, modified tables, and deleted tables.
--force, -f
Allows adding files that have merge conflicts. This option forces them into the staging area with conflict markers, requiring manual resolution before committing.
DESCRIPTION
dolt add is a fundamental command in Dolt, the version-controlled SQL database.
Similar to `git add`, it prepares changes from the working directory to be included in the next Dolt commit. These changes can include modifications to existing tables, the addition of new tables, or deletions. Users specify which changes to stage using pathspec (e.g., table names) or stage all changes with the `--all` option.
Staging is a crucial intermediate step, allowing users to carefully select and group related changes before permanently recording them in the Dolt history using `dolt commit`. It ensures that only intended modifications are part of a snapshot, providing granular control over database versioning.
CAVEATS
Staging changes with `dolt add` does not permanently save them; a subsequent `dolt commit` is required to record the changes in the database history.
Using `--all` will stage all untracked, modified, and deleted items, so exercise caution to avoid staging unintended changes. Be aware that tables with unresolved merge conflicts require the `--force` option to be added.
THE STAGING AREA
In Dolt, the staging area (also known as the index) is a temporary buffer where you collect changes from your working directory before committing them. `dolt add` moves changes into this area, allowing you to curate a snapshot of your database to be committed.
DATA VS. FILE STAGING
Unlike traditional Git which primarily stages file changes, `dolt add` is designed to stage changes to table schemas and table data. While it can also operate on SQL files or other tracked files, its primary power lies in managing granular database modifications.
HISTORY
The `dolt add` command has been a core component of the Dolt version control system since its public release by DoltHub in 2019. Its design directly mirrors the `git add` command, bringing the familiar concept of a staging area to relational databases. This allows users to prepare specific sets of schema and data modifications for atomic commits, a fundamental workflow for versioning data effectively.