You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `DOLT_REFLOG()` table function shows the history of named refs (e.g. branches and tags), which is useful when you want to understand how a branch or tag has changed over time to reference different commits, particularly for information that isn't surfaced through the `dolt_log` system table or `dolt_log()` table function. For example, if you use `dolt_reset()` to change the commit a branch points to, you can use `dolt_reflog()` to see what commit the branch was pointing to before it was moved to that commit. Another common use case for `dolt_reflog()` is to recreate a branch or tag that was accidentally deleted. The example section below shows how to recreate a deleted branch.
813
+
814
+
The data from Dolt's reflog comes from [Dolt's journaling chunk store](https://www.dolthub.com/blog/2023-03-08-dolt-chunk-journal/). This data is local to a Dolt database and never included when pushing, pulling, or cloning a Dolt database. This means when you clone a Dolt database, it will not have any reflog data until you perform operations that change what commit branches or tags reference.
815
+
816
+
Dolt's reflog is similar to [Git's reflog](https://git-scm.com/docs/git-reflog), but there are a few differences:
817
+
- The Dolt reflog currently only supports named references, such as branches and tags, and not any of Git's special refs (e.g. `HEAD`, `FETCH-HEAD`, `MERGE-HEAD`).
818
+
- The Dolt reflog can be queried for the log of references, even after a reference has been deleted. In Git, once a branch or tag is deleted, the reflog for that ref is also deleted and to find the last commit a branch or tag pointed to you have to use Git's special `HEAD` reflog to find the commit, which can sometimes be challenging. Dolt makes this much easier by allowing you to see the history for a deleted ref so you can easily see the last commit a branch or tag pointed to before it was deleted.
819
+
820
+
### Privileges
821
+
822
+
There are no special privileges required to use the `dolt_reflog()` table function.
823
+
824
+
### Options
825
+
826
+
```sql
827
+
DOLT_REFLOG()
828
+
DOLT_REFLOG(<ref_name>)
829
+
```
830
+
831
+
The `dolt_reflog()` table function can be called with no arguments or with one argument. If called without any arguments, it will return the full reference log, which lists changes from newest to oldest for all tracked references. If called with one argument, that argument is the name of a ref to query. This can be the name of a branch (e.g. "myBranch") or the name of a tag (e.g. "v1.1.4") or it can be the fully qualified ref path (e.g. "refs/heads/myBranch"). The `ref_name` parameter is case-insensitive.
832
+
833
+
### Schema
834
+
835
+
```text
836
+
+-----------------------+-----------+
837
+
| field | type |
838
+
+-----------------------+-----------+
839
+
| ref | TEXT |
840
+
| ref_timestamp | TIMESTAMP |
841
+
| commit_hash | TEXT |
842
+
| commit_message | TEXT |
843
+
+-----------------------+-----------+
844
+
```
845
+
846
+
### Example
847
+
848
+
The example below shows how to recreate a branch that was deleted by finding the last commit it referenced in Dolt's reflog.
849
+
850
+
```sql
851
+
-- Someone accidentally deletes the wrong branch!
852
+
call dolt_branch('-D', 'prodBranch');
853
+
854
+
-- After we realize the wrong branch has been deleted, we query the Dolt reflog on the same Dolt database instance
855
+
-- where the branch was deleted to see what commits the prodBranch branch has referenced. Using the same Dolt
856
+
-- instance is important, since reflog information is always local and not included when pushing/pulling databases.
0 commit comments