Skip to content

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 -a

Alias: m

Flags

FlagLongDescription
-a--allStage all changes before committing
-p--patchInteractively stage changes (prompts for each hunk)
-c--commitCreate a new commit instead of amending
-m--messageSpecify commit message

What it does

  1. Stages changes if requested (with -a or -p)
  2. Amends the current commit (default) or creates a new commit (with -c)
  3. Automatically restacks all children branches after the change
  4. 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 log

Because 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.