LogoLogo
DoltHubBlogDiscordGitHubDolt
  • Introduction
    • What Is Dolt?
    • Installation
      • Linux
      • Windows
      • Mac
      • Build from Source
      • Application Server
      • Docker
      • Upgrading
    • Getting Started
      • Version Controlled Database
      • Git For Data
      • Versioned MySQL Replica
    • Use Cases
      • Data Sharing
      • Data and Model Quality Control
      • Manual Data Curation
      • Version Control for your Application
      • Versioned MySQL Replica
      • Audit
      • Configuration Management
      • Offline First
  • Concepts
    • Dolt
      • Git
        • Commits
        • Log
        • Diff
        • Branch
        • Merge
        • Conflicts
        • Remotes
        • Working Set
      • SQL
        • Databases
        • Schema
        • Tables
        • Primary Keys
        • Types
        • Indexes
        • Views
        • Constraints
        • Triggers
        • Procedures
        • Users/Grants
        • Transactions
        • System Variables
      • RDBMS
        • Server
        • Backups
        • Replication
    • DoltHub/DoltLab
      • Permissions
      • Pull Requests
      • Issues
      • Forks
  • SQL Reference
    • Running the Server
      • Configuration
      • Access Management
      • Branch Permissions
      • Backups
      • Garbage Collection
      • Metrics
      • Replication
      • Troubleshooting
    • Version Control Features
      • Using Branches
      • Merges
      • Querying History
      • Using Remotes
      • Procedures
      • Functions
      • System Tables
      • System Variables
      • Saved Queries
    • SQL Language Support
      • Data Description
      • Expressions, Functions, Operators
      • Supported Statements
      • MySQL Information Schema
      • Collations and Character Sets
      • System Variables
      • Miscellaneous
    • Supported Clients
      • Programmatic
      • SQL Editors
    • Benchmarks and Metrics
      • Correctness
      • Latency
      • Import
  • CLI Reference
    • Commands
    • Git Comparison
  • Architecture
    • Overview
    • Storage Engine
      • Commit Graph
      • Prolly Trees
      • Block Store
    • SQL
      • Go MySQL Server
      • Vitess
  • Guides
    • Cheat Sheet
    • Contributing
      • dolt
      • go-mysql-server
    • MySQL to Dolt Replication
    • Importing Data
    • Integrations
  • Other
    • FAQ
    • Roadmap
    • Versioning
  • Products
    • Hosted Dolt
      • Getting Started
      • Notable Features
      • SQL Workbench
      • Cloning a Hosted Database
      • Using DoltHub as a Remote
      • Infrastructure
    • DoltHub
      • Data Sharing
      • API
        • Authentication
        • SQL
        • CSV
        • Database
        • Hooks
      • Continuous Integration
        • Getting Started
        • Workflow Reference
      • Transform File Uploads
      • Workspaces
    • DoltLab
    • Dolt Workbench
    • DoltgreSQL
Powered by GitBook
On this page
  • Setup and init
  • Stage and snapshot
  • Branch and merge
  • Diffing
  • Status and logs
  • History
  • Working with remotes
  • Advanced use cases

Was this helpful?

Edit on GitHub
Export as PDF
  1. Guides

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 server
Dolt CLI
Comments

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 server
Dolt CLI
Comments

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 server
Dolt CLI
Comments

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 server
Dolt CLI
Comments

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 server
Dolt CLI
Comments

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 server
Comments

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 server
Dolt CLI
Comments

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 server
Dolt CLI
Comments

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

PreviousVitessNextContributing

Last updated 1 year ago

Was this helpful?

Selects data from 3 commits ago
Sets this session to query data from 3 commits ago
Lists all branches
Shows which tables are modified or staged
Shows the commit history for the current branch
Selects every row from mytable at every point in history
Selects who first added the row with id = 1 to mytable
Lists remotes
Shows who last updated every row of a table
Lists which tables have conflicts after a merge
Lists the rows in conflict for mytable
Shows the parent commit(s) of a commit
Shows all commits on all branches
Ignores tables matching generated* (won't be added or committed)
Clones the post-no-preference/options database from DoltHub
Adds a table to the staging area
Removes staged tables, keeps working changes
Resets all staged and working changes to HEAD
Commits staged tables as a new snapshot
Stages and commits all tables
Creates a new branch
Switches to another branch
Creates a new branch and switches to it
Merges a branch into the checked out branch
Adds a new DoltHub remote
Fetches all branches from the remote
Fetch and merge commits from the remote tracking branch
Push local commits of branch myBranch to remote origin
Push local commits to the remote tracking branch
Creates a new commit which reverts the changes in a prior commit
Resolves conflicts in mytable by taking their changes
Creates a new tag at the HEAD of mybranch
Applies the changes in a commit to the current branch HEAD
Checks for constraint violations (e.g. after checks had been disabled)
Runs garbage collection to compact the size of the database on disk
Begins an interactive rebase session
Shows the working diff for mytable
Shows statistics for the diff of mytable
Shows the diff between the last two commits for mytable
Shows the staged diff for mytable
Shows diff between branches two branches for mytable
Shows the checked out branch (marked with * on CLI)
Shows the commit history for myBranch
Shows the commits on branchA that are not on branchB
Shows the commit hash of a ref
Shows a three-dot diff
Creates SQL statements to apply a diff between two revisions
Shows schema differences for a table between two commits
Shows the history of a ref, included deleted refs
Shows the common ancestor of two commits