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
  • What is a Working Set?
  • How to use Working Sets
  • Difference between Git Working Sets and Dolt Working Sets
  • Example
  • Make changes in a working set
  • See what's changed in your working set
  • Reset a change to your working set
  • Checkout on the Command Line
  • Checkout in SQL server

Was this helpful?

Edit on GitHub
Export as PDF
  1. Concepts
  2. Dolt
  3. Git

Working Set

What is a Working Set?

Dolt has three kinds of changes: committed, staged and working. The working set is the set of changes that has not been staged or committed. To stage a change in a table you add it to the staging set. The staging set is committed by issuing a commit command and supplying the appropriate metadata.

If you start a Dolt SQL server and start making changes, you are making changes to the working set. If you never make a commit, your working set is a standard MySQL database. So, a way to think about your working set is Dolt without version control features, just a standard MySQL relational database.

How to use Working Sets

Working sets are used to isolate changes to your database from committed schema or data. Each branch gets it's own working set so you can make changes in isolation. If you don't like the changes made to a working set, you can reset or checkout to the previous commit.

Difference between Git Working Sets and Dolt Working Sets

Git working sets change files. Dolt working sets change tables.

On the command line, working set changes do follow to the newly checked out branch, just like Git. However, in SQL server mode, working set changes are not transferred to the newly checked out branch when you do a dolt checkout. The working set changes stay on the branch they were originally made. This change was made to account for multiple users using the same branch in SQL server mode.

Example

Make changes in a working set

$ dolt sql -q "insert into docs values (3,0)";
Query OK, 1 row affected
$ dolt status
On branch main
Changes not staged for commit:
  (use "dolt add <table>" to update what will be committed)
  (use "dolt checkout <table>" to discard changes in working directory)
	modified:       docs

See what's changed in your working set

$ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ c341qjl0eholuiu1k4pvujre7mc75qtc
+++ b/docs @ f7isl5tqm92ovogh6v8seq26lsjmiknk
+-----+----+----+
|     | pk | c1 |
+-----+----+----+
|  +  | 3  | 0  |
+-----+----+----+
docs $ dolt sql -q "select * from dolt_diff_docs where to_commit='WORKING'"
+-------+-------+-----------+----------------+---------+---------+----------------------------------+-------------------------+-----------+
| to_c1 | to_pk | to_commit | to_commit_date | from_c1 | from_pk | from_commit                      | from_commit_date        | diff_type |
+-------+-------+-----------+----------------+---------+---------+----------------------------------+-------------------------+-----------+
| 0     | 3     | WORKING   | NULL           | NULL    | NULL    | uhumidn2e7ucan59jk9vuabm7r5osggs | 2021-12-07 01:14:46.684 | added     |
+-------+-------+-----------+----------------+---------+---------+----------------------------------+-------------------------+-----------+

Reset a change to your working set

docs $ dolt status
On branch main
Changes not staged for commit:
  (use "dolt add <table>" to update what will be committed)
  (use "dolt checkout <table>" to discard changes in working directory)
	modified:       docs
docs $ dolt checkout docs
docs $ dolt status
On branch main
nothing to commit, working tree clean
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0  | 0  |
| 1  | 1  |
| 2  | 2  |
+----+----+

Checkout on the Command Line

docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0  | 0  |
| 1  | 1  |
| 2  | 2  |
+----+----+
docs $ dolt branch
  feature-branch                                	
* main                                          	
docs $ dolt sql -q "insert into docs values (3,0)";
Query OK, 1 row affected
docs $ dolt checkout -b follow-me
Switched to branch 'follow-me'
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0  | 0  |
| 1  | 1  |
| 2  | 2  |
| 3  | 0  |
+----+----+
docs $ dolt status
On branch follow-me
Changes not staged for commit:
  (use "dolt add <table>" to update what will be committed)
  (use "dolt checkout <table>" to discard changes in working directory)
	modified:       docs
docs $ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ c341qjl0eholuiu1k4pvujre7mc75qtc
+++ b/docs @ f7isl5tqm92ovogh6v8seq26lsjmiknk
+-----+----+----+
|     | pk | c1 |
+-----+----+----+
|  +  | 3  | 0  |
+-----+----+----+

Checkout in SQL server

mysql> insert into docs values (4,4);
mysql> select * from docs ;
+----+----+
| pk | c1 |
+----+----+
| 0  | 0  |
| 1  | 1  |
| 2  | 2  |
| 3  | 0  |
| 4  | 4  |
+----+----+
mysql> call dolt_checkout('follow-me');
+--------+
| status |
+--------+
| 0      |
+--------+
mysql> select * from docs ;
+----+----+
| pk | c1 |
+----+----+
| 0  | 0  |
| 1  | 1  |
| 2  | 2  |
| 3  | 0  |
+----+----+
PreviousRemotesNextSQL

Last updated 1 year ago

Was this helpful?