Documentation
Mid-Stack Edits
Amend or add commits to any branch in your stack.
gs modify
Modify the current branch by amending its commit or creating a new commit. Descendants are automatically restacked.
# Amend current commit
gs modify
# Amend with a new message
gs modify -m "Updated commit message"
# Stage all changes and amend
gs modify -a
# Stage interactively and amend
gs modify -p
# Create new commit instead of amending
gs modify -c -m "New commit message"
# Short alias
gs m -aAlias: m
Flags
| Flag | Long | Description |
|---|---|---|
-a | --all | Stage all changes before committing |
-p | --patch | Interactively stage changes (prompts for each hunk) |
-c | --commit | Create a new commit instead of amending |
-m | --message | Specify commit message |
What it does
- Stages changes if requested (with
-aor-p) - Amends the current commit (default) or creates a new commit (with
-c) - Automatically restacks all children branches after the change
- Handles conflicts during restacking interactively
When to use
- After code review feedback on a stacked branch
- To add forgotten changes to the current commit
- To split changes into a new commit on the current branch
- Anytime you need to edit a branch that has children
Workflow: editing a branch mid-stack
# Navigate to the branch you want to edit
gs checkout feat-auth
# Make your changes
# ...edit files...
# Stage and amend, children restack automatically
gs modify -a -m "update auth middleware"
# Verify the stack is consistent
gs logBecause gs modify restacks direct children automatically, the branches above feat-auth are rebased onto the updated commit. For deeper stacks, follow up with gs stack restack to propagate further.