Cheat Sheet

This cheat sheet briefly summarizes the main version-control features of Dolt with simple examples. Most commands can be executed on the command line or in a SQL session. Most Dolt commands take the same options as Git commands.

Click links in the comments section to read docs for the feature.

Setup and init

SQL serverDolt CLIComments

CREATE DATABASE mydb;

dolt init

Creates a new Dolt database

CALL DOLT_CLONE('post-no-preference/options');

dolt clone post-no-preference/options

Stage and snapshot

SQL serverDolt CLIComments

CALL DOLT_ADD('myTable');

dolt add myTable

CALL DOLT_RESET();

dolt reset

CALL DOLT_RESET('--hard');

dolt reset --hard

CALL DOLT_COMMIT('-m', 'a commit');

dolt commit -m 'a commit'

CALL DOLT_COMMIT('-Am', 'a commit');

dolt commit -Am 'a commit'

Branch and merge

SQL serverDolt CLIComments

SELECT * FROM dolt_branches;

dolt branch

CALL DOLT_BRANCH('myBranch');

dolt branch myBranch

CALL DOLT_CHECKOUT('myBranch');

dolt checkout myBranch

CALL DOLT_CHECKOUT('-b', 'myBranch');

dolt checkout -b myBranch

CALL DOLT_MERGE('myBranch');

dolt merge mybranch

Diffing

SQL serverDolt CLIComments

SELECT * FROM dolt_diff('HEAD', 'WORKING', 'mytable');

dolt diff mytable

SELECT * FROM dolt_diff_stat('HEAD', 'WORKING', 'mytable');

dolt diff --stat mytable

SELECT * FROM dolt_diff('HEAD~', 'HEAD', 'mytable');

dolt diff HEAD~ HEAD mytable

SELECT * FROM dolt_diff('HEAD', 'STAGED', 'mytable');

dolt diff --cached mytable

SELECT * FROM dolt_diff('branchA', 'branchB', 'mytable');

dolt diff branchA branchB mytable

Status and logs

SQL serverDolt CLIComments

SELECT * FROM dolt_status;

dolt status

SELECT active_branch();

dolt branch

SELECT * FROM dolt_log;

dolt log

SELECT * FROM dolt_log('myBranch');

dolt log myBranch

SELECT * FROM dolt_log('branchB..branchA');

dolt log branchB..branchA

History

History querying is specific to the SQL server and has no command line equivalent.

SQL serverComments

SELECT * FROM mytable AS OF 'HEAD~3';

USE mydb/HEAD~3;

SELECT * FROM dolt_history_mytable;

SELECT committer FROM dolt_history_mytable where id = 1 order by commit_date LIMIT 1;

Working with remotes

SQL serverDolt CLIComments

CALL DOLT_REMOTE('add', 'myRemote', 'myOrg/myRepo');

dolt remote add myRemote/myRepo

SELECT * FROM dolt_remotes;

dolt remote

CALL DOLT_FETCH();

dolt fetch

CALL DOLT_PULL();

dolt pull

CALL DOLT_PUSH('origin', 'myBranch');

dolt push origin myBranch

CALL DOLT_PUSH();

dolt push

Advanced use cases

SQL serverDolt CLIComments

SELECT HASHOF('main');

dolt show main

SELECT * from dolt_blame_mytable;

dolt blame mytable

SELECT * FROM dolt_diff('branch1...branch2');

dolt diff branch1...branch2

CALL DOLT_REVERT('gtfv1qhr5le61njimcbses9oom0de41e');

dolt revert gtfv1qhr5le61njimcbses9oom0de41e

SELECT * FROM DOLT_PATCH('main', 'WORKING');

dolt patch main

SELECT * FROM dolt_conflicts;

dolt conflicts cat

SELECT * FROM [dolt_conflicts_mytable];

dolt conflicts cat mytable

CALL DOLT_CONFLICTS_RESOLVE('--theirs', 'mytable');

dolt conflicts resolve --theirs mytable

CALL DOLT_TAG('tag1', 'myBranch');

dolt tag tag1 mybranch

CALL DOLT_CHERRY_PICK('qj6ouhjvtrnp1rgbvajaohmthoru2772');

dolt cherry-pick qj6ouhjvtrnp1rgbvajaohmthoru2772

SELECT * FROM dolt_schema_diff('main', 'branch1', 'mytable');

dolt diff --schema main branch1

CALL DOLT_VERIFY_CONSTRAINTS();

dolt verify-constraints

CALL DOLT_GC();

dolt gc

CALL DOLT_REBASE('--interactive', 'main');

dolt rebase --interactive main

SELECT * FROM dolt_reflog('mybranch');

dolt reflog mybranch

SELECT * FROM dolt_commit_ancestors where commit_hash = HASHOF('main');

No equivalent

SELECT DOLT_MERGE_BASE('main', 'feature');

dolt merge-base main feature

SELECT * FROM dolt_commits;

No equivalent

INSERT INTO dolt_ignore VALUES ("generated_*", true);

No equivalent

Last updated