git-rebase
Use when rebasing branches in this repo; handling non-fast-forward push rejections; deciding whether to merge, rebase, cherry-pick, or force-with-lease…
от Kilo-Org★ 25 звёзд на GitHub
Установить git-rebase в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Git rebase and PR branch hygiene
Keep PR history clean. Treat rebases, non-fast-forward push rejections, and branch rewrites as topology problems, not file-content problems.
Required repo rules
- Read and follow root
AGENTS.mdand any nestedAGENTS.mdbefore changing files. - Never use
--force,--no-verify, or hook-bypass flags without explicit user approval. - Prefer
git push --force-with-leaseovergit push --force; still ask first. - If hooks/checks fail, diagnose and fix or ask; do not bypass silently.
- Run
pnpm formatbefore committing. For verification, prefer targeted checks; avoid fullpnpm typecheckby default because it is slow. - For migration conflicts: never hand-write or hand-edit generated migration SQL, snapshots, or journal entries. Delete branch-local generated migration artifacts, rerun
pnpm drizzle generate, then re-append intentional backfill SQL after generated DDL using--> statement-breakpointseparators.
Start every rebase/branch-cleanup task
git status --short --branch
branch=$(git branch --show-current)
git fetch origin main
git fetch origin "$branch" || true
git rev-list --count origin/main..HEAD
git log --oneline --decorate origin/main..HEAD
git log --oneline --left-right --graph HEAD...origin/$branch || true
Then state:
- current branch;
- whether the worktree is clean;
- local-only commit count and subjects;
- remote-only commits, if any;
- expected reviewable commit count, if known;
- whether the remote branch appears authoritative, stale, or uncertain.
Do not start a rebase with an unexplained dirty worktree. If on main or another protected/base branch, stop and ask.
If the user approves stashing dirty work, use a named stash and restore it after the rebase:
git stash push -u -m "pre-rebase-$branch-$(date +%Y%m%d%H%M%S)"
git stash list -1
After the rebase and verification, run git stash pop, report restored tracked/untracked files, and leave them unstaged unless the user asked otherwise.
Before rewriting local history
Create a backup branch unless the user explicitly declines:
backup="backup/${branch}-pre-rebase-$(date +%Y%m%d%H%M%S)"
git branch "$backup" HEAD
Use git rebase origin/main for normal base refreshes. Use interactive rebase only when the user asked to reorder/squash/edit commits or when you first explain the intended rewrite.
If post-rebase cleanup creates files that belong in an earlier logical commit, state the intended local rewrite before using git commit --fixup plus git rebase -i --autosquash or git commit --amend. Rerun final topology verification afterward.
After the rebase, verify topology and content:
git status --short --branch
git rev-list --count origin/main..HEAD
git log --oneline --decorate origin/main..HEAD
git diff --stat origin/main...HEAD
git range-diff origin/main...$backup origin/main...HEAD || true
After resolving conflicts, check resolved files for conflict markers and whitespace errors before final reporting:
rg -n '^<<<<<<<|^=======$|^>>>>>>>' <resolved-files> || true
git diff --check
If final content must match a backup/bad-history branch exactly:
git diff --quiet HEAD "$backup"
echo $?
Exit code 0 means file trees match.
Migration conflict procedure
When rebase conflicts touch packages/db/src/migrations/:
Identify branch-local generated migration artifacts. During an interrupted rebase, prefer the pre-rebase backup branch if
HEADno longer contains all branch commits:git diff --name-only --diff-filter=A origin/main...$backup -- packages/db/src/migrations git diff --name-only --diff-filter=A origin/main...HEAD -- packages/db/src/migrationsDo not manually resolve generated migration SQL, snapshots, or journal JSON.
Remove branch-local generated migration SQL, snapshot, and journal entries involved in the conflict.
If generated snapshot or journal conflicts block
git rebase --continue, stage the current/base migration metadata as a temporary conflict resolution, then continue the rebase.After the rebase reaches the target branch tip, rerun generation from the rebased schema:
pnpm drizzle generateRe-append any intentional backfill SQL after generated DDL with
--> statement-breakpointseparators.If regenerated migration files belong in an earlier logical commit, use the post-rebase cleanup guidance above.
Prefer a single regenerated migration per feature branch when it has not shipped.
Non-fast-forward push rejection
If git push is rejected as non-fast-forward, stop. Do not run git pull, git merge origin/$branch, or git merge reflexively.
Inspect divergence:
git fetch origin "$branch"
git log --oneline --left-right --graph HEAD...origin/$branch
git rev-list --count origin/main..HEAD
git rev-list --count origin/main..origin/$branch
Interpretation:
<= local-only commits.>= re
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл git-rebase?
Use when rebasing branches in this repo; handling non-fast-forward push rejections; deciding whether to merge, rebase, cherry-pick, or force-with-lease; recovering from polluted PR history; resolving migration conflicts during rebase. Enforces repo git safety rules, clean reviewable history, and explicit approval gates for branch rewrites.
Как установить скилл git-rebase?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл git-rebase запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet 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…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…