en un clic
distribute-changes
// Distribute uncommitted changes across a Graphite stack using a backup branch
// Distribute uncommitted changes across a Graphite stack using a backup branch
Execute a list of tasks as a stack of PRs using Graphite (`gt`). Each task becomes one branch, one commit, one PR. Use when the project uses stacked PRs via Graphite and you have multiple tasks to ship.
Stacked PRs with Graphite CLI (gt)
Expert guidance on Neovim configuration, plugin management, lazy.nvim, LSP setup, and editor workflow optimization
Walk a Graphite stack bottom-to-top, fixing PR review comments on each branch
Stacked PRs with Charcoal CLI (charcoal)
Generate feature documentation — PRDs, RFCs, ADRs, plans, technical docs, tasks, guides, testing docs, runbooks, and changelogs — individually or as a progressive pipeline covering a feature's full lifecycle
| name | distribute-changes |
| description | Distribute uncommitted changes across a Graphite stack using a backup branch |
| user_invocable | true |
Take a batch of uncommitted changes and distribute them across existing and/or new branches in a Graphite stack. Uses a backup branch as a safe reference point.
Optional: [description] — a short label for the backup branch (defaults to
"changes").
First, preserve all uncommitted changes in a backup branch.
# Create backup branch and commit everything
git checkout -b backup/<description>-<date>
git add -A
git commit -m "backup: all uncommitted changes from <description>"
# Return to the original branch
git checkout <original-branch>
If changes are already committed on the current branch and just need splitting, skip the backup — the current branch IS the backup.
List all changed files and group them by destination:
# See all files in the backup
git diff HEAD backup/<name> --name-only
Group each file into one of:
Decision rules:
Present the grouping to the user for approval before proceeding.
Process existing PRs from bottom to top of the stack:
# 1. Switch to the target branch
gt checkout <branch-name>
# 2. Pull specific files from the backup
git checkout backup/<name> -- \
path/to/file1.ex \
path/to/file2.ex
# 3. Amend the branch
gt modify --all
# 4. If restack conflicts occur, resolve them
git add .
gt continue
Repeat for each existing branch that needs changes.
Verify progress after each branch:
git diff HEAD backup/<name> --name-only
For changes that don't belong in any existing PR:
# 1. Go to the top of the stack
gt top
# 2. Pull files for the first new PR
git checkout backup/<name> -- \
path/to/new_file1.ex \
path/to/new_file2.ex
# 3. Create a new stacked branch
gt create --all --message "type(scope): description"
# 4. Repeat for additional new PRs
git checkout backup/<name> -- path/to/other_files.ex
gt create --all --message "type(scope): other changes"
# Submit the entire stack
gt submit --stack --publish --ai
# Verify no files remain undistributed
git diff HEAD backup/<name> --name-only
# Should be empty (or only show the backup commit itself)
# Confirm clean state
git status
gt log short
If changes include git submodules, handle them first — commit directly in the submodule before distributing main repo changes:
cd packages/<submodule>
git add <files>
git commit -m "fix(scope): description"
cd ../..
When changes are small and still unstaged, skip the backup branch and use selective staging:
# Stage only files for this PR
git add path/to/file1.ex path/to/file2.ex
gt create -m "feat(scope): first group"
# Stage next group
git add path/to/file3.ex
gt create -m "fix(scope): second group"
gt submit --stack --publish --ai
git checkout stash@{0} -- <file> — it brings the entire file
from stash, leaking changes from other branchesgit diff