LogoLogo
BlogDiscordGitHubDoltgres
  • Introduction
    • What is Doltgres?
    • Installation
    • Getting Started
  • Concepts
    • Git
      • Commits
      • Log
      • Diff
      • Branch
      • Merge
      • Conflicts
      • Remotes
      • Working Set
    • SQL
      • Databases
      • Schema
      • Tables
      • Primary Keys
      • Types
      • Indexes
      • Views
      • Constraints
      • Triggers
      • Functions
      • Procedures
      • Users/Grants
      • Transactions
      • System Variables
    • RDBMS
      • Server
      • Backups
      • Replication
  • Guides
    • Cheat Sheet
    • Replication from Postgres
  • 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
      • Functions
      • System Tables
      • System Variables
    • SQL Language Support
      • Supported Functions and Operators
      • Supported Types
      • Supported SQL Commands
      • System Catalog Schema
    • Supported Clients
      • Programmatic
    • Benchmarks
      • Correctness
      • Latency
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
  1. Guides

Cheat Sheet

This cheat sheet briefly summarizes the main version-control features of Doltgres with simple examples.

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

Setup and init

SQL
Comments

CREATE DATABASE mydb;

Creates a new Doltgres database

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

Stage and snapshot

SQL
Comments

SELECT DOLT_ADD('myTable');

SELECT DOLT_RESET();

SELECT DOLT_RESET('--hard');

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

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

Branch and merge

SQL
Comments

SELECT * FROM dolt_branches;

SELECT DOLT_BRANCH('myBranch');

SELECT DOLT_CHECKOUT('myBranch');

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

SELECT DOLT_MERGE('myBranch');

Diffing

SQL
Comments

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

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

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

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

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

Status and logs

SQL
Comments

SELECT * FROM dolt_status;

SELECT active_branch();

SELECT * FROM dolt_log;

SELECT * FROM dolt_log('myBranch');

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

History

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

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

SELECT * FROM dolt_remotes;

SELECT DOLT_FETCH();

SELECT DOLT_PULL();

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

SELECT DOLT_PUSH();

Advanced use cases

SQL
Comments

SELECT HASHOF('main');

SELECT * from dolt_blame_mytable;

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

SELECT DOLT_REVERT('gtfv1qhr5le61njimcbses9oom0de41e');

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

SELECT * FROM dolt_conflicts;

SELECT * FROM [dolt_conflicts_mytable];

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

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

SELECT DOLT_CHERRY_PICK('qj6ouhjvtrnp1rgbvajaohmthoru2772');

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

SELECT DOLT_VERIFY_CONSTRAINTS();

SELECT DOLT_GC();

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

SELECT * FROM dolt_reflog('mybranch');

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

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

SELECT * FROM dolt_commits;

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

PreviousReplicationNextReplication from Postgres

Last updated 21 days ago

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
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
Shows the commit history for myBranch
Shows the commits on branchA that are not on branchB
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
Shows the commit hash of a ref
Shows a three-dot diff
Creates a new commit which reverts the changes in a prior commit
Creates SQL statements to apply a diff between two revisions
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
Shows schema differences for a table between two commits
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 history of a ref, included deleted refs
Shows the common ancestor of two commits