Getting Started With Graphite CLI: Complete Setup Guide

Get Started With Graphite CLI And Upgrade With Gitar

Key Takeaways

  1. Graphite CLI enables stacked pull requests that automatically rebase, so you can split large features into small PRs under 200 lines.
  2. Install via Homebrew on macOS or Linux, or via npm globally, then authenticate with gt auth login for smooth GitHub integration.
  3. Use gt create to start branches, gt log to visualize stacks, and gt push plus gt submit to open pull requests.
  4. Run gt sync to keep stacks updated and manage your trunk with gt upstream so upstream changes do not cause merge conflicts.
  5. Pair Graphite stacks with Gitar AI to auto-fix CI failures and review feedback, which increases team throughput.

How Graphite CLI Handles Stacked Pull Requests

Graphite CLI is a git branching tool that enables stacked pull requests, which are dependent PRs that automatically rebase when earlier PRs merge. Graphite uses a stack-based methodology for Stacked Pull Requests, allowing developers to layer changes for parallel feature work and quicker integration with smaller code reviews. This CLI tool solves merge hell by breaking large features into 5–10 small PRs under 200 lines each, instead of shipping one massive change.

Graphite supports stacked pull requests where developers create dependent PRs that automatically rebase upon earlier PR merges to reduce conflicts. The tool integrates with GitHub and provides a clear interface for managing stacked workflows. Engineers at companies including Vercel, Snowflake, and The Browser Company use Graphite to maintain stacks of 5–10 PRs, each under about 200 lines, which allows independent reviews while keeping work unblocked.

The main benefit is faster merges through smaller, focused changes that reviewers can approve quickly. You ship incremental improvements while you continue building the next feature. Install Gitar now—automatically fix broken builds, start shipping higher quality software faster.

Prerequisites for Using Graphite CLI

Set up Git and confirm you have access to a GitHub or GitLab repository before installing Graphite CLI. Graphite CLI requires Git version compatibility and Node.js when you install it with npm.

For smooth stacked PR workflows, install the Gitar GitHub App alongside Graphite CLI. Gitar automatically fixes CI failures and applies review feedback in your PRs, which removes manual cleanup that slows your team. Start your 14-day Team Plan free trial to see automated healing on your stacks.

Gitar provides automated root cause analysis for CI failures. Save hours debugging with detailed breakdowns of failed jobs, error locations, and exact issues.
Gitar provides detailed root cause analysis for CI failures, saving developers hours of debugging time

Graphite Download, Installation & Authentication Steps

Use these steps to install and authenticate Graphite CLI quickly.

1. Install Graphite CLI

For macOS and Linux users:

brew install graphite

For all platforms via npm:

npm i -g @withgraphite/graphite-cli

Graphite CLI version 1.5.3 or higher is recommended to be installed via npm. Graphite CLI can be installed via Homebrew for macOS, Linux via Linuxbrew, or via npm as @withgraphite/graphite-cli.

2. Authenticate with GitHub

gt auth login

This command detects your GitHub token automatically. Authentication involves configuring the Graphite token, which is detected automatically.

Troubleshooting Authentication: If authentication fails, run gt whoami to check your current auth status. On Windows or Git Bash, update or remove outdated credentials in Windows Credential Manager.

Create Your First Stack with gt create

Follow this sequence to create your first stacked PR workflow.

1. Create your first branch

gt create feature-login

This command creates a new branch off your trunk branch, usually main or master.

2. Make changes and commit

Edit your files, then commit as usual:

git add . git commit -m “Add login form component”

3. Visualize your stack

gt log

This output shows your current branch stack structure.

4. Push your branch

gt push

5. Create a dependent branch

gt create feature-validation

This command creates a second branch that depends on your first branch. Repeat this pattern to build a stack of three to five related PRs.

When you open these PRs on GitHub, Gitar can automatically fix CI failures with a single comment. Gitar analyzes failure logs, generates fixes with full codebase context, and commits working solutions. Install Gitar now—automatically fix broken builds, start shipping higher quality software faster.

AI-powered bug detection and fixes with Gitar. Identifies error boundary issues, recommends solutions, and automatically implements the fix in your PR.

Syncing Stacks & Managing Your Trunk Branch

Handle upstream changes early so your stacked workflow stays clean.

Set your trunk branch:

gt upstream new

Specify the Trunk branch, typically main, during configuration.

Sync with upstream changes:

gt sync

This command pulls upstream changes and rebases your stack automatically.

Submit your PRs:

gt submit

Restack functionality in Graphite allows restacking a selected branch and its parents, with an option for Restack Full Stack to include children branches, which handles conflicts during the process.

Graphite CLI Command Cheat Sheet

Command

Description

Example

gt create

Start new stack branch

gt create feat-login

gt log

View current stack

gt log –short

gt push

Push current stack

gt push

gt sync

Rebase on upstream

gt sync

gt submit

Submit PRs for review

gt submit

gt track

Track stacked branch

gt track existing-branch

gt pop

Drop top branch

gt pop

gt upstream

Set trunk branch

gt upstream new

gt auth

Authenticate with GitHub

gt auth login

gt whoami

Check auth status

gt whoami

Graphite Troubleshooting Guide

Use these quick fixes for common Graphite issues.

Authentication failures: Run gt whoami to check status. For Graphite CLI, authentication issues usually come from underlying Git auth problems.

Reference lock errors: Remove stale lock files with rm .git/refs/locked-file.lock.

“Not a git repository” error: Navigate to the correct repository directory using the cd command.

CI failures in stacks: Common CI failures with Graphite include build errors from misconfigured scripts or incompatible tool versions. Run tests locally before pushing and confirm your environment variables are set correctly.

Boost Graphite Stacks with Gitar AI Code Review

Graphite manages stacked PRs, and Gitar’s healing engine removes blockers by fixing issues that would stall your stacks.

Gitar bot automatically fixes code issues in your PRs. Watch bugs, formatting, and code quality problems resolve instantly with auto-apply enabled.

Graphite Agent provides AI-assisted reviews with full codebase context, suggesting fixes for issues like logic errors and vulnerabilities in stacked PRs. Gitar goes further by implementing those fixes instead of only suggesting them.

Screenshot of Gitar code review findings with security and bug insights.
Gitar provides automatic code reviews with deep insights

Capability

Traditional Code Review

Gitar

Auto-fix CI failures

No

Yes

Single comment interface

Noisy notifications

Clean dashboard

Stacks support

Partial

Full (GitHub/GitLab/CircleCI)

Validate fixes work

Hope-based

CI-validated

Graphite acquisition by Cursor in 2026 enables planned integrations for tighter local development to PR workflows, and Gitar already delivers the automation layer that makes stacked PRs efficient.

The ROI is clear: teams report cutting time spent on CI and review issues from one hour per developer per day to about 15 minutes. For a 20-developer team, that shift equals roughly $750,000 in annual productivity savings.

Let Gitar handle all CI failures and code review interrupts so you stay focused on your next task.
Let Gitar handle all CI failures and code review interrupts so you stay focused on your next task.

Install Gitar now—automatically fix broken builds, start shipping higher quality software faster.

FAQ

What is the difference between Graphite and regular Git?

Graphite builds on top of Git to provide stacked pull request functionality. When you merge an earlier PR in a stack, Graphite automatically rebases all dependent branches, which removes the manual rebase work that would otherwise be required. Regular Git requires you to manage these dependencies yourself.

How does Gitar work with Graphite stacks?

Gitar integrates as a GitHub App that monitors your PRs for CI failures and review feedback. When issues occur, Gitar analyzes the problem, generates a fix with full codebase context, validates that it works, and commits the solution so your PRs stay green.

Is there a free trial available?

Gitar offers a 14-day free trial of the Team Plan with unlimited repositories and users. This trial gives you full access to auto-fix capabilities, custom rules, and all integrations so you can measure the impact on your development velocity before you choose a paid plan.

How do I download and install Graphite?

Install Graphite CLI via Homebrew with brew install graphite on macOS or Linux, or via npm with npm i -g @withgraphite/graphite-cli on any platform. After installation, authenticate with gt auth login and you are ready to start stacking.

What should I do if gt create is not working?

First, confirm you are in a Git repository and have authenticated with gt auth login. Check that your trunk branch is set correctly with gt upstream new. If problems continue, verify your Git configuration and confirm you have the latest version of Graphite CLI installed.

Conclusion: Pair Graphite Stacks with Gitar Automation

Graphite CLI changes how teams handle complex feature development by enabling efficient stacked pull requests. With $52 million in Series B funding and adoption by major companies, Graphite has proven its value in modern development workflows.

The strongest velocity gains appear when you pair Graphite’s stacking capabilities with Gitar’s healing engine. Graphite organizes your work into manageable stacks, and Gitar keeps those stacks green by automatically fixing CI failures and applying review feedback.

This combination delivers measurable ROI through faster merges from smaller PRs, less context switching due to automated fixes, and higher code quality from AI-powered review. In the 2026 AI-accelerated development landscape, this approach is essential for maintaining competitive engineering velocity.

Install Gitar now—automatically fix broken builds, start shipping higher quality software faster.