LinuxCommandLibrary

dolt-checkout

Switch between dolt branches or commits

TLDR

Switch to a branch

$ dolt checkout [branch_name]
copy

Revert unstaged changes to a table
$ dolt checkout [table]
copy

Create new branch and switch to it
$ dolt checkout -b [branch_name]
copy

Create new branch based on a specified commit and switch to it
$ dolt checkout -b [branch_name] [commit]
copy

SYNOPSIS

dolt checkout [] ||

PARAMETERS

-b
    Create a new branch and switch to it.

--force
    Forces a checkout even if the working set has uncommitted changes. Use with caution, as this can lead to data loss.

--detach
    Check out a commit in 'detached HEAD' state.


    The name of the branch to switch to.


    The commit hash to checkout.


    The name of the table to checkout. The table name must be qualified by branch or commit name (branch/tablename or commit/tablename)

DESCRIPTION

The dolt checkout command allows you to switch between different branches and commits within a Dolt repository. It's analogous to git checkout, but operates on Dolt's version-controlled database. You can use it to examine the state of the database at a particular point in history, create new branches to work on features, or revert to a previous version. dolt checkout modifies the .dolt directory, which stores metadata about the current branch, commit, and working set. It also updates the working set, which represents the current state of the database in your working directory. This command will checkout a branch, a commit, or a table.

CAVEATS

Checking out a commit directly (detached HEAD) will leave you in a state where any new commits you make will not be attached to any branch.
You'll need to create a new branch to save your changes. Using --force can result in lost work if you have uncommitted changes. When you checkout a single table, it is copied into your working set. Subsequent reads from that table use the version of the table that was copied.
This continues until the working set is explicitly updated by committing or resetting. In these cases, the table version specified by branch or commit is used to update the working set.

EXAMPLES

Switch to the 'main' branch:
dolt checkout main

Create a new branch named 'feature/new-feature' and switch to it:
dolt checkout -b feature/new-feature

Check out a specific commit:
dolt checkout abc123def456

Check out table 'mytable' on the branch 'develop':
dolt checkout develop/mytable

SEE ALSO

dolt branch(1), dolt commit(1), dolt reset(1), dolt merge(1)

Copied to clipboard