git-rebase-patterns
БесплатноБез исполняемых скриптовНе проверенAdvanced git rebase — linear history, stacked PRs, --update-refs, --onto. Use when rebasing branches, cleaning history, managing PR stacks, or fixing…
от laurigates★ 61 звезда на GitHubОб этом скилле
Git Rebase Patterns
Advanced rebase techniques for maintaining linear history, managing stacked PRs, and cleaning up commit history.
When to Use This Skill
| Use this skill when... | Use something else when... |
|---|---|
| Rebasing feature branches onto updated main | Creating branches → git-branch-naming |
| Cleaning up commit history before PR | Creating PRs → git-branch-pr-workflow |
| Managing stacked PRs (PR chains) | Simple commits → git-commit-workflow |
| Converting merge-heavy branches to linear | Basic git operations → git-cli-agentic |
Linear History Basics
Trunk-Based Development
# Feature branch lifecycle (keep short - max 2 days)
git switch main
git pull origin main
git switch -c feat/user-auth
# Daily rebase to stay current
git switch main && git pull
git switch feat/user-auth
git rebase main
# Interactive cleanup before PR
git rebase -i main
# Squash, fixup, reword commits for clean history
# Push and create PR
git push -u origin feat/user-auth
Squash Merge Strategy
Maintain linear main branch history:
# Manual squash merge
git switch main
git merge --squash feat/user-auth
git commit -m "feat: add user authentication system
- Implement JWT token validation
- Add login/logout endpoints
- Create user session management
Refs #123"
Interactive Rebase Workflow
Clean up commits before sharing:
# Rebase last 3 commits
git rebase -i HEAD~3
# Common rebase commands:
# pick = use commit as-is
# squash = combine with previous commit
# fixup = squash without editing message
# reword = change commit message
# drop = remove commit entirely
# Example rebase todo list:
pick a1b2c3d feat: add login form
fixup d4e5f6g fix typo in login form
squash g7h8i9j add form validation
reword j1k2l3m implement JWT tokens
Advanced Rebase Flags
Reapply Cherry-Picks (--reapply-cherry-picks)
Problem: After merging trunk into your feature branch multiple times (via git merge main), you want to rebase onto fresh trunk. Default rebase behavior may create conflicts or duplicate commits.
Solution: --reapply-cherry-picks detects commits that were already applied via merge and drops the merge commits, keeping only your original changes.
# Scenario: You merged main into your branch a few times
git log --oneline
# abc123 Merge branch 'main' into feat/auth
# def456 feat: add login endpoint
# ghi789 Merge branch 'main' into feat/auth
# jkl012 feat: add user validation
# Rebase onto fresh main, dropping merge commits
git fetch origin
git rebase --reapply-cherry-picks origin/main
# Result: Clean linear history with just your feature commits
# jkl012 feat: add user validation
# def456 feat: add login endpoint
When to use:
- After merging trunk into your branch to resolve conflicts
- Converting a merge-heavy branch to linear history
- Before creating a PR to clean up integration merges
Update Refs (--update-refs)
Problem: With stacked PRs (PR chains), rebasing one branch requires manually rebasing all dependent branches. Moving commits between branches in the stack is painful.
Solution: --update-refs automatically updates all branches in the chain when you rebase. Combined with interactive rebase, you can reorganize commits across your entire PR stack in one operation.
--update-refsis local-only: it moves the branches but leaves the PRs, their bases, and the force-pushes to you. For a stack registered with GitHub,gh stack rebase/gh stack syncdo the cascade and the push and PR update — seegit-plugin:git-stacked-prs.
# Scenario: Stacked PRs
# main <- feat/auth-base <- feat/auth-oauth <- feat/auth-refresh
# Rebase the entire stack onto updated main
git switch feat/auth-refresh
git rebase --update-refs main
# All three branches (auth-base, auth-oauth, auth-refresh) are updated
# No manual rebasing of each branch needed
# Interactive rebase to move commits between branches
git rebase -i --update-refs main
# In the editor, move commit lines around to reorganize the stack:
# pick abc123 feat: add auth base # Will update feat/auth-base
# pick def456 feat: add OAuth support # Will update feat/auth-oauth
# pick ghi789 feat: add token refresh # Will update feat/auth-refresh
Stacked PR workflow with update-refs:
# Create PR stack
git switch main
git pull origin main
# First PR: Base authentication
git switch -c feat/auth-base
# ... make commits ...
git push -u origin feat/auth-base
# Second PR: OAuth (depends on first)
git switch -c feat/auth-oauth
# ... make commits ...
git push -u origin feat/auth-oauth
# Third PR: Token refresh (depends on second)
git switch -c feat/auth-refresh
# ... make commits ...
git push -u origin feat/auth-refresh
# Main updated - rebase entire stack
git fetch origin
git switch feat/auth-refresh
git rebase --update-refs origin/main
# All branches rebased in one c
Установить git-rebase-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Bash(git rebase *)Bash(git fetch *)Bash(git switch *)Bash(git pull *)Bash(git log *)Bash(git merge *)Bash(git add *)Bash(git commit *)Bash(git reflog)ReadFAQ
Что делает скилл git-rebase-patterns?
Advanced git rebase — linear history, stacked PRs, --update-refs, --onto. Use when rebasing branches, cleaning history, managing PR stacks, or fixing merge-heavy branches.
Как установить скилл git-rebase-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл git-rebase-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic