# Branch graph

See your commit history and branches as a graph.

The **branch graph** draws the history of your project: every commit, and where branches split and merge. From any commit you can open its changes, compare it with a branch or a tag, branch or tag from it, or restore your files to it.

The branch graph with commit rows, the main branch chip, authors, times and short hashes, and the actions menu of one commit open.

## What you can do

- Scroll the history of your current branch, of every branch, or of the branches and tags you pick.
- Search commits by message, hash or author, step through the matches, and keep only one author's commits.
- Open a commit to see the files it changed, and open their changes.
- Compare a commit with its remote branch, its merge base, or any branch or tag, or mark any two commits and open what changed between them.
- Create a branch or a tag on any commit, or switch to it.
- Cherry-pick a commit onto your current branch.
- Restore your files to a commit, or undo the last commit.
- Add a commit to the chat, or ask Lyna to explain its changes.
- Point at a commit to read its details, or select it to keep them open, and open the graph of your branches on GitHub.

## Open the graph

In **Code** mode, open **Source Control** and choose **Open branch graph**. The graph opens in the editor area. The **Graph** section of Source Control shows the same history in the side bar.

The toolbar holds the search box, **Refs shown**, **Go to current commit**, **Refresh** and **More actions**, where you choose **View as list** or **View as tree** for the files of an open commit. With a GitHub repository linked, **Fetch**, **Pull** and **Push** sit there too. **New branch** is in the graph's header. Choose **Load More...** at the bottom to load older history.

**Refs shown** picks what the graph draws: **Auto** (your current branch, its remote and its base), **All** (every branch, remote branch and tag), or the branches and tags you check.

**More actions** also holds the graph's options, kept for the project:

- **Show incoming changes** and **Show outgoing changes** show or hide the rows for commits on your remote branch that you do not have yet, and for your commits that are not on it yet.
- **Badges**: **All refs** shows every branch and tag on a commit's row; **Refs in the filter** shows only those **Refs shown** draws, plus your current branch.
- **Load more on scroll**, on by default, loads older history as you reach the end. Turn it off to load it only with **Load More...**.

## Act on a commit

Click a commit to open it: its changed files appear under it, and a click on a file opens its changes. Right-click a commit, or select it and press `Shift + F10`, to open its actions:

| Action                                                                      | What it does                                                                                                            |
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Open Changes**                                                            | Opens the changes the commit made, in a page in place of your tabs.                                                     |
| **Open on GitHub**                                                          | Opens the commit on GitHub. Only when the project is linked to a repository.                                            |
| **Checkout**                                                                | Switches to a branch that points at this commit.                                                                        |
| **Checkout (Detached)**                                                     | Switches your files to this commit without a branch. Not offered on the current commit (HEAD).                          |
| **Create Branch...** / **Create Tag...**                                    | Starts a branch or adds a tag on this commit.                                                                           |
| **Delete Branch** / **Delete Tag**                                          | Removes a branch or a tag on this commit, after you confirm. The main branch and your current branch are never offered. |
| **Cherry Pick**                                                             | Copies the changes of this commit onto your current branch. Not offered on the current commit.                          |
| **Restore to This Commit**                                                  | Puts your files back as they were at this commit, after you confirm. Not offered on the current commit.                 |
| **Undo Commit**                                                             | Only on the current commit, and never on a merge. Removes the commit and keeps its changes staged.                      |
| **Compare with Remote** / **Compare with Merge Base** / **Compare with...** | Opens the differences between this commit and its remote branch, its merge base, or a branch or tag you pick.           |
| **Copy Commit Hash** / **Copy Commit Message**                              | Copies the commit id or its message.                                                                                    |
| **Add to Chat** / **Explain Changes**                                       | Adds the commit and its files to your chat message, or asks Lyna to explain them.                                       |

> [!NOTE]
>
> **Restoring never deletes history**
>
> **Restore to This Commit** makes a new commit that records the restore. The later commits stay in the history, so you can go forward again.

If a cherry-pick conflicts with your current code, Lyna cancels it and your files stay as they were.

## Compare a commit with a branch or tag

1. ### Open the commit's actions

   Right-click the commit, or select it and press `Shift + F10`.
2. ### Choose Compare with...

   Search the branches and tags, then pick one.
3. ### Read the differences

   The files that differ open as diffs, titled with the two sides.

## Commit details

Point at a commit to see its card: the author, when it was made (how long ago, then the full date), the whole message, how many files changed with the lines added and removed, its branches and tags, and at the bottom the short hash (choose it to open the commit), a copy button and **Open on GitHub**. One card shows at a time, and it stays inside the code panel.

Point at a changed file under an open commit to see what the commit changed in it: the file's name and folder, the lines added and removed, its status, and the diff itself. A binary file, a change too large to preview, or a file whose content did not change says so instead. **Open Changes** opens the full diff and **Open File** opens the file (not offered for a deleted file). The file's card replaces the commit's card, so one card still shows at a time.

## The GitHub graph

In the **GitHub** view of a linked project, choose **Open GitHub graph**, next to **Check sync status**. The **GitHub graph** opens in the editor area: every branch on GitHub with its commits, drawn like the branch graph.

- Its toolbar holds **Fetch**, **Pull** and **Push**, with the same search, **Refs shown** and **More actions**. **All** is every branch on GitHub, **Auto** the branch your project tracks.
- A commit's actions fit a commit on GitHub: **Open Changes**, **Open on GitHub**, **Checkout (Detached)**, **Create Branch...**, **Create Tag...**, **Cherry Pick**, the compares, the copies and the chat. **Compare with Remote** compares with the GitHub branch your project tracks.
- While your project's machine starts, or when GitHub cannot be read, the graph says so with **Try again**.

The **Commits** tab of the GitHub view shows the same graph in the side bar.

## Who can do what

People with view access can open commits, compare them, copy hashes and messages, and add them to the chat. Checking out, creating and deleting branches and tags, cherry-picking, restoring and undoing are for editors.

## Shortcuts

| Action                                 | Shortcut                                               |
| -------------------------------------- | ------------------------------------------------------ |
| Move between rows                      | `Up` / `Down`, `Home` / `End`, `Page Up` / `Page Down` |
| Open or close a commit or folder       | `Right` / `Left`                                       |
| Open the commit, or the file's changes | `Enter`                                                |
| Open the commit's actions              | `Shift + F10`                                          |

## Related

- [Git](/features/code/git): Commit, branch, stash and merge.
- [Version history](/features/projects/version-history): Restore the whole project to an earlier version.
- [GitHub and pull requests](/features/code/github-and-pull-requests): Share your branches on GitHub.
