LinuxCommandLibrary

dolt-init

Initialize a new Dolt repository

TLDR

Initialize a new Dolt data repository in the current directory

$ dolt init
copy

Initialize a new Dolt data repository creating a commit with the specified metadata
$ dolt init --name "[name]" --email "[email]" --date "[2021-12-31T00:00:00]" [[-b|--initial-branch]] "[branch_name]"
copy

SYNOPSIS

dolt init [<path>]

PARAMETERS

<path>
    Optional. The directory where the new Dolt repository will be initialized. If omitted, the repository is initialized in the current working directory.

DESCRIPTION

dolt-init initializes a new Dolt database repository in the current directory or a specified path. Analogous to git init for Git repositories, dolt-init sets up the necessary Dolt internal structures, including the .dolt directory. This hidden directory stores all database history, schema, and data. This command is the foundational step and must be executed before any other Dolt commands that operate on a repository (e.g., dolt add, dolt commit, dolt status).

When executed without a path, it initializes the repository in the current working directory. If a path is provided, dolt-init will create the directory if it doesn't exist and then initialize the repository within it. It establishes an empty main branch, preparing the directory for database version control. The command ensures the chosen location is ready to be managed as a Dolt database, allowing users to begin tracking schema and data changes.

CAVEATS

Initializing a Dolt repository inside an already existing .dolt directory is not permitted and will result in an error or a message indicating that the repository is already initialized. The .dolt directory contains critical internal data; direct manual manipulation of its contents is strongly discouraged as it can corrupt the repository. Always use Dolt commands to interact with the repository's state.

IDEMPOTENCY

Running dolt-init in a directory that is already a Dolt repository typically has no effect or provides an informational message stating that it is already initialized. It generally does not re-initialize or corrupt an existing repository.

.DOLT DIRECTORY

Upon initialization, a hidden directory named .dolt is created at the root of the repository. This directory is crucial as it stores all the version history, including commits, branches, and the underlying data. It should not be manually modified or deleted.

HISTORY

Dolt was developed by DoltHub (formerly Liquidata) and open-sourced in 2019, introducing the concept of a Git-like version-controlled database. The dolt-init command has been a core component since its inception, mimicking the behavior and purpose of git init to provide the essential first step for users to begin versioning their SQL databases. Its design reflects Dolt's philosophy of bringing familiar Git semantics to database management.

SEE ALSO

dolt add(1), dolt commit(1), dolt status(1), dolt clone(1), git init(1)

Copied to clipboard