g2g
Stacked branches with git alone — Graphite and GitHub optional
- Language
- Go
- Version
- 0.29.0
- License
- MIT
- Category
- Dev Tool
A local stacked-branch structure tool. It records a branch forest in the repository's git common directory, then uses that structure to inspect, restack, update and publish a stack. Recording and maintaining structure needs only git — Graphite is an optional source it can read, mirror to and import from, and GitHub is a publishing target it projects a linear path onto. It never flattens a fork merely to publish it.
Features
Structure without Graphite — a branch forest recorded in git's common directory; neither Graphite nor GitHub is required
A forest, not a chain — each branch has at most one parent, a parent may have many children, and a repo may have several roots
Preview first, always — every mutating command renders a plan and requires --apply; it re-discovers and revalidates before mutating
Fails closed on ambiguity — track never picks a parent when the answer is unclear, and two open PRs on one branch refuses rather than guessing
Never guesses a trunk from its name — multiple declared trunks on an ancestry demand an explicit --trunk that must be a real ancestor
Graphite as an optional source — import a described stack, mirror local structure back, or pin --from graphite per command
Projects a linear path onto GitHub native stacks — link prints and validates the exact gh stack link command
Atomic, lease-protected push — every selected ref advances together or none of them do
Separate discovery and mutation budgets — a slow read can never cancel a push or PR creation halfway
Blocked previews name the repair — gt sync, g2g submit or g2g link, depending on why the state is stale
Copyable output by design — nothing but whitespace shares a command's line, and PR numbers are OSC 8 hyperlinks where supported
Deterministic for scripts — color off for pipes, CI, NO_COLOR and TERM=dumb; --json and --porcelain never emit links
Tests use fake executables on PATH — no authentication and no network required
Install
Homebrew
$ brew install shhac/tap/g2g AI Agent Skill
$ npx skills add shhac/agent-skills --skill g2g --global GitHub Release (macOS)
$ curl -L https://github.com/shhac/g2g/releases/latest/download/g2g-darwin-arm64.tar.gz | tar xz Go Install
$ go install github.com/shhac/g2g/cmd/g2g@latest Build from Source
$ git clone https://github.com/shhac/g2g.git && cd g2g && make build Getting Started
Record the stack you are already on, inspect it, then preview any change. g2g stays local in a repository that has never used Graphite — it will not create Graphite state just to find out whether Graphite applies.
01 · Record local structure once
$ g2g track --stack --trunk main --apply --stack derives the ancestry, --apply writes it. Replace main with this stack's root where it cannot be inferred.
02 · Look at what it recorded
$ g2g graph graph, track and untrack read git and the local store only. Nothing calls out.
03 · Preview before you change anything
$ g2g restack Every mutating command previews first. Add --apply once you have read the plan; it revalidates before it acts.
04 · Project the stack onto GitHub
$ g2g link --branch feature/top --apply Resolves the linear path, prints the exact gh stack link command it validated, then runs it. A one-PR path prints Nothing to link rather than building an invalid command.
Usage
$ g2g track --stack --trunk main --apply $ g2g graph $ g2g status $ g2g restack $ g2g push --branch feature/top --apply $ g2g link --branch feature/top $ g2g link --branch feature/middle --scope path