LinuxCommandLibrary

dolt-commit

Save changes to the Dolt database

TLDR

Commit all staged changes, opening the editor specified by $EDITOR to enter the commit message

$ dolt commit
copy

Commit all staged changes with the specified message
$ dolt commit [[-m|--message]] "[commit_message]"
copy

Stage all unstaged changes to tables before committing
$ dolt commit [[-a|--all]]
copy

Use the specified ISO 8601 commit date (defaults to current date and time)
$ dolt commit --date "[2021-12-31T00:00:00]"
copy

Use the specified author for the commit
$ dolt commit --author "[author_name] <[author_email]>"
copy

Allow creating an empty commit, with no changes
$ dolt commit --allow-empty
copy

Ignore foreign key warnings
$ dolt commit [[-f|--force]]
copy

SYNOPSIS

dolt commit [-a | --all] [-m <message>] [--author <author>] [--date <date>] [--allow-empty] [--summary] [--] [<table> ...]

PARAMETERS

-a, --all
    Stages modified and deleted tables, then commits all changes.

-m <message>, --message <message>
    Sets the commit message.

--author <author>
    Overrides author name and email (format: 'Name <email>').

--date <date>
    Overrides commit timestamp (ISO 8601 format).

--allow-empty
    Allows committing even with no changes.

--summary
    Prints a summary of the commit after execution.

DESCRIPTION

The dolt commit command records the current state of staged tables in a Dolt repository, creating a new commit object that captures a snapshot of the database schema and data. Similar to git commit, it advances the branch pointer and enables versioning, branching, and merging for databases. Before committing, use dolt add to stage specific table changes. If no tables are specified, it commits all staged changes. Dolt commits include metadata like author, date, and message, facilitating collaboration and history tracking. Empty commits are disallowed by default to prevent meaningless history entries, but can be enabled with --allow-empty. Post-commit, the working set updates, and dolt status reflects a clean state. This command is essential for persistent changes in Dolt's Git-like workflow, supporting diffs, logs, and reprodcution of database states over time.

CAVEATS

Requires a Dolt repository (run dolt init first). Fails if no changes are staged unless --allow-empty or -a is used. Tables must be added via dolt add before selective commits.

EXAMPLES

dolt commit -m "Add users table"
dolt commit -am "Update all tables"
Commits all staged tables with message; stages and commits everything.

NOTES

Commits create immutable history; use dolt checkout or dolt branch for navigation.

HISTORY

Introduced with Dolt 0.1.0 in 2019 by DoltHub team to mirror Git semantics for SQL databases. Evolved to support advanced features like schema changes and large datasets, with ongoing enhancements for performance.

SEE ALSO

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

Copied to clipboard