# Git Graph

A commit graph with branch lanes and merges that plays in from the oldest commit, with search, branch and author filters, Shift-click range compare, and details with parents and diff stats.

- Page and source: https://uibrik.com/components/git-graph
- Install (Pro, needs a license key, see https://uibrik.com/docs/pro): `npx shadcn@latest add @uibrik-pro/git-graph`
- Packages: none beyond React
- Import: `import { GitGraph } from "@/components/uibrik/git-graph/git-graph"`

Where to use the Git Graph React component:

- **Developer tools and Git clients**: Lanes are laid out like git log --graph, so branches, merges and tags read the way developers expect. Pairs with [Code Block](https://uibrik.com/components/code-block).
- **Release and deploy history**: Tags and HEAD sit on their commits, and selecting one shows who shipped what with its diff stats. Pairs with [Deploy Pipeline](https://uibrik.com/components/deploy-pipeline).
- **Version history for any document**: Hovering a version lights up everything it was built from, which makes branching edits easy to follow. Pairs with [Prompt Versions](https://uibrik.com/components/prompt-versions).

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| animate | `boolean` | `true` | Play the history in from the oldest commit on mount. |
| speed | `number` | `0.08` | Seconds between one commit and the next during the playback. |
| showDetails | `boolean` | `true` | Show the selected commit's or range's details under the graph. |
| searchable | `boolean` | `true` | Show the search field above the graph. |
| colors | `string[]` | `["#5b7bd6","#d4875a","#3f9e7a","#a372cf"]` | Lane colours, from the leftmost lane. |
| commits | `Commit[]` | `SAMPLE_COMMITS` | Newest first, like git log. |
| Commit | `{ hash: string; message: string; author: string; date: string; parents: string[]; refs?: string[]; additions?: number; deletions?: number; files?: number }` |  | `refs` takes "main", "HEAD -> main" or "tag: v2.4.0". Parents missing from the list run off the bottom. |
| selected | `string \| null` |  | Selected hash (controlled). Pair with onSelect. |
| defaultSelected | `string \| null` |  | Hash selected on mount. Defaults to the newest commit. |
| onSelect | `(hash: string) => void` |  | Called when a commit is clicked, picked with the arrow keys or reached from a parent link. Shift-click compares a range instead. |
| avatars | `Record<string, string>` | `SAMPLE_AVATARS` | Photo URL for each author name. Authors without one show their initials. |
| className | `string` |  | Classes for the card. |
