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

01

Structure without Graphite — a branch forest recorded in git's common directory; neither Graphite nor GitHub is required

02

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

03

Preview first, always — every mutating command renders a plan and requires --apply; it re-discovers and revalidates before mutating

04

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

05

Never guesses a trunk from its name — multiple declared trunks on an ancestry demand an explicit --trunk that must be a real ancestor

06

Graphite as an optional source — import a described stack, mirror local structure back, or pin --from graphite per command

07

Projects a linear path onto GitHub native stacks — link prints and validates the exact gh stack link command

08

Atomic, lease-protected push — every selected ref advances together or none of them do

09

Separate discovery and mutation budgets — a slow read can never cancel a push or PR creation halfway

10

Blocked previews name the repair — gt sync, g2g submit or g2g link, depending on why the state is stale

11

Copyable output by design — nothing but whitespace shares a command's line, and PR numbers are OSC 8 hyperlinks where supported

12

Deterministic for scripts — color off for pipes, CI, NO_COLOR and TERM=dumb; --json and --porcelain never emit links

13

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

>_ Record the ancestry you are standing on
$ g2g track --stack --trunk main --apply
>_ See the stack and its PR states
$ g2g graph
>_ What is stale, and what repairs it
$ g2g status
>_ Preview a rebase cascade
$ g2g restack
>_ Atomic, lease-protected push of the whole stack
$ g2g push --branch feature/top --apply
>_ Preview a branch without checking it out
$ g2g link --branch feature/top
>_ Stop at one branch instead of its full stack
$ g2g link --branch feature/middle --scope path