Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

git

БесплатноБез исполняемых скриптовНе проверен

Use this skill for complex git operations including rebases, merge conflict resolution, cherry-picking, branch management, PR branch upkeep, or repository…

hyperb1issот hyperb1iss★ 39 звёзд на GitHub

Об этом скилле

Git Operations

Advanced git workflows: rebase surgery, conflict resolution, and coexistence in shared multi-agent repos.

PR Branch Upkeep

The most-run workflow: keeping your own PR branch current against a moving main.

Capture the target base and remote branch tip, preserve a backup, rebase when required, and run checks on the resulting content. Recheck remote state before pushing. A base that keeps moving is not a reason for an endless rebase loop: use the captured base and the repository's merge policy. When current-main ancestry is required, check it explicitly:

git merge-base --is-ancestor origin/main HEAD && echo "based on current main"

Review etiquette: while a reviewer (bot, human, or agent) is actively reading, hold pushes. Batch fixes, then one rebase+push when the review lands. Freshness loops run at push boundaries.

Pushing rewritten history

Pin the lease to the remote tip whose work you inspected before rewriting. Background fetches can refresh a tracking ref and weaken an implicit lease. Recheck with ls-remote before pushing; if the tip changed, inspect and reconcile that work instead of copying its SHA into a fresh lease:

git ls-remote origin refs/heads/<branch>   # compare with the previously captured and inspected remote tip
git push --force-with-lease=refs/heads/<branch>:<expected-sha> origin HEAD:<branch>

On a "stale info" rejection, diagnose with ls-remote before any retry. Observed causes: auto-delete-on-merge removed the branch, a typo'd lease SHA, or the remote legitimately moved. Bare --force is not an escalation path.

After the base squash-merges

When a parent PR squash-merges, its commits vanish from main's ancestry. A plain rebase replays them as ghosts. Detect the merge type first: squash, rebase-merge, and merge-commit each leave different ancestry.

Situation Move
Parent PR squash-merged git rebase --onto <new-base> <old-base-sha>: only your own commits replay
Replay keeps conflicting / branch polluted Rebuild as main + delta: one git diff --binary patch from the backup, applied onto fresh main; prove with range-diff
Pushing fixes to an old branch Verify PR open-state first. A squash-merged PR's branch is dead
Stacked chain Cascade bottom-up with --onto, per-level backup, push bottom-first (validators diff against origin/<base>)

Pre-Surgery Ref Reality

Local refs and the forge's view routinely disagree. Before any history surgery:

  • Inspect the fetch mapping when tracking refs matter. git fetch origin main updates origin/main under the usual configured refspec; use git fetch origin refs/heads/main:refs/remotes/origin/main when an explicit mapping is needed
  • git rev-parse --is-shallow-repository: shallow history can hide the real merge base; deepen when ancestry is incomplete
  • Cross-check gh pr view base/head oids against local rev-parse / ls-remote
  • Probe conflict shape for free: git merge-tree --write-tree origin/main <branch>. A clean merge predicts textual compatibility, not semantic correctness or whether branch policy requires a restack
  • Pin every operation to a captured SHA, never a moving ref

Conflict Resolution

Conflicts are intent-merges, not side-picks. Read all three index stages (git show :1:<file> :2:<file> :3:<file>) plus the pre-rebase tip before resolving, and ask: did upstream obsolete this branch's mechanism? When main replaced it with a newer abstraction, plug your feature into main's shape instead of resurrecting the old one. Preserve invariant-explaining comments. Pace by risk class (slower on security-sensitive files). Close with a mechanical conflict-marker scan; survivors are real.

Situation Strategy
Encoded artifact (lockfile, SOPS, generated schema) Never text-merge the encoding. Merge the meaning, re-encode with the canonical tool, roundtrip-verify.
Simple content conflict Resolve as a union of both sides' intent; prefer the smallest diff.
Large structural conflict Consider --ours/--theirs + manual reapply of the smaller side.
Полный SKILL.md на GitHub

Установить git в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/evidence.md

FAQ

Что делает скилл git?

Use this skill for complex git operations including rebases, merge conflict resolution, cherry-picking, branch management, PR branch upkeep, or repository archaeology. Activates on mentions of git rebase, merge conflict, cherry-pick, git history, branch cleanup, git bisect, worktree, force push, force-with-lease, PR branch, stacked PR, squash-merge, lease, shared repo, or complex git operations.

Как установить скилл git?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл git запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить git с