# Log

## What is a log?

The Doltgres log is a way to visualize the Doltgres commit graph in an intuitive way. When viewing the log, you are seeing a topologically sorted commit order that led to the commit you have checked out. The log is an audit trail of commits.

In Doltgres, you can visualize the log of a database, a table, a row, or even a cell.

Log is usually filtered by branch. Any commits not reachable in the graph from the current commit will be omitted from the log.

## How to use logs

Logs are useful in reverting the database to a previous state. You determine the state of the database you want via log and then use other Doltgres commands to change the database to a different state.

Logs are useful when trying to track down why the database is in a particular state. You use log to find the commits in question and usually follow up with diffs (i.e. differences) between two commits you found in the log.

Logs are useful in audit. If you would like to ensure a particular value in the database has not changed since the last time you read it, log is useful in verifying this.

## Difference between Git log and Doltgres log

Conceptually and practically log on the command line is very similar between Git and Doltgres. A table is akin to a file in Git.

Doltgres has additional log functionality beyond Git. You can produce a log of any cell (i.e. row, column pair) in the database using a SQL query against the `dolt_history_<tablename>` system table.

## Example

### Commit Log

```sql
select * from dolt_log;
+----------------------------------+-----------+------------------+-----------------------------------+----------------------------+
| commit_hash                      | committer | email            | date                              | message                    |
+----------------------------------+-----------+------------------+-----------------------------------+----------------------------+
| u73s2mb1ho4mj1ldkof939vampo93bld | Tim Sehn  | tim@dolthub.com  | 2021-12-06 10:45:11.148 -0800 PST | This is a commit           |
| bo318l76dq3bdvu1ie84d4nmv4hpi4km | Tim Sehn  | tim@dolthub.com | 2021-12-02 16:55:00.101 -0800 PST | This is a commit           |
| jcj6q9c9nsveh72eadsms9i9k9ii1e55 | Tim Sehn  | tim@dolthub.com | 2021-12-02 16:54:35.87 -0800 PST  | Initialize data repository |
+----------------------------------+-----------+------------------+-----------------------------------+----------------------------+
```

### Cell History

```sql
select * from dolt_history_employees where id=0 order by commit_date;
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
| id   | last_name | first_name | start_date | commit_hash                      | committer | commit_date             |
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
|    0 | Sehn      | Tim        | NULL       | 13qfqa5rojq18j84d1n2htjkm6fletg4 | Tim Sehn  | 2022-06-07 16:39:32.066 |
|    0 | Sehn      | Timothy    | NULL       | uhkv57j4bp2v16vcnmev9lshgkqq8ppb | Tim Sehn  | 2022-06-07 16:41:49.847 |
|    0 | Sehn      | Tim        | 2018-09-08 | pg3nfi0j1dpc5pf1rfgckpmlteaufdrt | Tim Sehn  | 2022-06-07 16:44:37.513 |
|    0 | Sehn      | Timothy    | 2018-09-08 | vn9b0qcematsj2f6ka0hfoflhr5s6p0b | Tim Sehn  | 2022-06-07 17:10:02.07  |
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.doltgres.com/concepts/git/log.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
