Git Rebase Onto Branch (grob) is an interactive command-line tool that makes git rebase --onto intuitive and safe. Available as both a standalone git subcommand and a Zsh plugin, it uses fzf to provide a visual, step-by-step workflow for rebasing commit ranges between branches.
Perfect for managing stacked pull requests, feature branches, and complex git workflows.
Git rebase onto (git rebase --onto <target> <upstream> <branch>) is powerful but difficult to visualize and error-prone. grob simplifies git rebasing by:
- π― Visual branch selection with fuzzy finding
- π Live commit previews showing diffs, stats, and metadata
- β Safety checks preventing rebases with uncommitted changes
- π Perfect for stacked PRs and feature branch workflows
- π Fast and efficient - no need to memorize complex
HEAD~Nsyntax
grob-demo-final-mp4.mp4
If you work with stacked pull requests (Branch B based on Branch A, which is based on main), you often face this scenario:
- Branch A gets updated, amended, or squashed
- Branch B still references the old version of Branch A
- You need to move Branch B onto the new Branch A without ghost commits
This requires git rebase --onto, which is complex to construct manually.
grob makes stacked PR management effortless:
- π― Select the updated Branch A (target)
- π Select the first commit unique to Branch B (base)
- β Review and confirm the rebase operation
No more calculating commit hashes or HEAD~N references manually!
- π Interactive Branch Selection: Fuzzy find branches with
fzfand preview git history - π Rich Commit Previews: View commit messages, authors, dates, file stats, and full diffs
- π‘οΈ Safety First: Dirty worktree check prevents rebasing with uncommitted changes
- π Cross-Platform: Works on macOS (BSD tools) and Linux (GNU tools)
- π¨ Clean Terminal UI: Formatted summary cards with proper alignment
- βοΈ Git Flag Passthrough: Full support for
git rebaseflags (-i,--autosquash,-Xours, etc.) - π¦ Multiple Install Options: Homebrew, manual install, or Oh-My-Zsh plugin
- β‘ Fast Workflow: No need to look up commit SHAs or calculate
HEAD~Noffsets
Choose your preferred installation method:
Install as a git subcommand - works seamlessly with your existing git workflow:
brew tap sspathak/tap
brew install git-grobThen invoke with git:
git grob # Run the interactive rebase tool
git grob -i # With interactive mode
git grob --autosquash # With autosquash enabledInstall the standalone executable:
# Download and install
curl -o /usr/local/bin/git-grob https://raw.githubusercontent.com/sspathak/zsh-grob/main/git-grob
chmod +x /usr/local/bin/git-grob
# Use it as a git subcommand
git grobRequirements: Zsh must be available at /usr/bin/env zsh
Install as a Zsh plugin for a shorter command (grob instead of git grob):
# Clone into Oh-My-Zsh custom plugins
git clone https://github.com/sspathak/zsh-grob ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/grobThen enable in your ~/.zshrc:
plugins=(git fzf grob) # Add 'grob' to your plugins arrayReload your shell:
source ~/.zshrcNow invoke with the shorter command:
grob # Same functionality as 'git grob'
grob -i # With interactive mode
grob --autosquash # With autosquash enabledRun the interactive rebase tool:
git grob # If installed via Homebrew or manual install
grob # If installed as Oh-My-Zsh pluginPass any git rebase flags to customize behavior:
git grob -i # Interactive rebase mode (edit, squash, reword commits)
git grob --autosquash # Auto-squash commits marked with fixup!/squash!
git grob -Xours # Use "ours" merge strategy for conflicts
git grob -i --autosquash # Combine multiple flagsAll unrecognized flags are passed directly to the underlying git rebase --onto command.
Use fzf fuzzy finder to select the destination branch where commits should land.
- β¬οΈβ¬οΈ Navigate with arrow keys
- π Type to filter branches
- π Preview window shows branch history
- β΅ Press Enter to select
Select the oldest commit to move (inclusive selection).
- All commits from this one to
HEADwill be rebased - Preview shows commit details: author, date, stats, and full diff
- Color-coded file changes help identify the right commit
A summary card displays:
βββββββββββββββββββββββββββββββββββββββββββββββ
β Target Branch: feature-branch-a β
β Commit Count: 5 β
β Starting At: abc123f β
β Extra Flags: -i --autosquash β
β Command: git rebase --onto ... β
βββββββββββββββββββββββββββββββββββββββββββββββ
- Press
yto execute the rebase - Press
nto abort safely
# Scenario: Branch B is based on old version of Branch A
# Branch A has been updated, need to rebase Branch B
git checkout branch-b
git grob
# Step 1: Select 'branch-a' (the updated target)
# Step 2: Select first commit unique to branch-b
# Step 3: Review and confirm with 'y'
# Result: branch-b now cleanly based on updated branch-a- Zsh - The script is written in Zsh
- fzf - Required for interactive fuzzy finding (installation guide)
- Git - Version 1.7.0+ (for
git rebase --ontosupport)
Contributions welcome! This project helps developers manage complex git workflows more easily.
Repository: github.com/sspathak/zsh-grob
MIT License
git rebase tool, interactive git rebase, git rebase onto, stacked pull requests, stacked PRs, git workflow, feature branch management, git subcommand, zsh plugin, fzf git, git automation, rebase helper, git cli tool