Treat LLM conversations as a versioned, branching Git repository.
Every prompt and response is committed as a node. You can branch mid-conversation to explore different directions, then merge the insights back together — with the LLM acting as the merge tool.
Each session lives in a directory with a real Git repo under the hood. Conversations are stored in a CONTEXT.md file (the "living document"). Every exchange is a commit, so the full history of your thinking is preserved and diffable.
- Branch to explore a different angle without losing your current thread
- Merge branches back together — the LLM performs a three-way semantic merge, synthesizing insights from both lines of thought
- Checkout any branch to resume that conversation thread
pip install git-brainOr from source:
git clone https://github.com/youruser/git-brain
cd git-brain
pip install -e .Requires Python 3.10+.
git-brain uses LiteLLM internally, so it works with any major provider. Set two environment variables (or put them in a .env file):
| Variable | Purpose |
|---|---|
GITBRAIN_MODEL |
LiteLLM model string (default: claude-3-5-sonnet-20241022) |
<PROVIDER>_API_KEY |
API key for the chosen provider |
GITBRAIN_API_BASE |
Optional custom endpoint (for OpenAI-compatible APIs) |
# Anthropic (default)
GITBRAIN_MODEL=claude-3-5-sonnet-20241022
ANTHROPIC_API_KEY=sk-ant-...
# OpenAI
GITBRAIN_MODEL=gpt-4o
OPENAI_API_KEY=sk-...
# Groq (fast, free tier available)
GITBRAIN_MODEL=groq/llama-3.3-70b-versatile
GROQ_API_KEY=gsk_...
# Ollama (local, no key needed)
GITBRAIN_MODEL=ollama/llama3.1
# Google Gemini
GITBRAIN_MODEL=gemini/gemini-1.5-pro
GEMINI_API_KEY=...
# OpenRouter
GITBRAIN_MODEL=openrouter/google/gemini-flash-1.5
OPENROUTER_API_KEY=sk-or-...
# Any OpenAI-compatible endpoint (e.g. Venice AI)
GITBRAIN_MODEL=openai/google/gemma-3-27b-it
OPENAI_API_KEY=sk-vca_...
GITBRAIN_API_BASE=https://api.venice.ai/api/v1mkdir my-research && cd my-research
git-brain init "Distributed systems study"git-brain prompt "What are the key trade-offs in consensus algorithms?"Responses stream to the terminal. Each exchange is committed as a node.
# Branch off to explore a different angle
git-brain branch -b raft-deep-dive
git-brain prompt "Explain Raft's leader election in detail"
# Meanwhile, main stays where it was
git-brain checkout main
git-brain prompt "How does Paxos handle network partitions?"# Back on main, merge the Raft research in
git-brain merge raft-deep-diveThe LLM performs a three-way merge (base → ours, base → theirs), integrates unique insights, resolves conflicting conclusions, and appends a ## Merge Synthesis section summarizing what came from each branch.
Preview without committing:
git-brain merge raft-deep-dive --dry-rungit-brain status # current branch, node count, last commit
git-brain log # commit history table
git-brain log -n 50 # show more commits
git-brain show # display latest node
git-brain show 3 # display node 3
git-brain branch # list all branches
git-brain checkout main # switch branch
git-brain edit # open CONTEXT.md in $EDITORAll conversation history lives in CONTEXT.md in the session directory. Each node looks like:
## Node 3 · 2026-04-25 14:32
**>** What are the key trade-offs in consensus algorithms?
**Claude:**
The fundamental trade-offs in consensus algorithms center around...
---Because it's plain Markdown in a Git repo, you can git diff, git log -p, and navigate history with any standard Git tooling alongside the git-brain commands.
| Command | Description |
|---|---|
git-brain init [title] |
Initialize a new session |
git-brain prompt <text> |
Send a prompt, stream response, commit node |
git-brain branch |
List branches |
git-brain branch -b <name> |
Create and switch to a new branch |
git-brain checkout <name> |
Switch to a branch |
git-brain checkout -b <name> |
Create and switch to a new branch |
git-brain merge <branch> |
LLM-assisted merge into current branch |
git-brain merge <branch> --dry-run |
Preview merge without committing |
git-brain log [-n N] |
Show commit history |
git-brain status |
Show branch, node count, last commit |
git-brain show [node] |
Display a node (default: latest) |
git-brain edit |
Open living document in $EDITOR |