Back to skills
extension
Category: Development & EngineeringNo API key required

git-branch-maintenance

Use when a task is Git-only branch maintenance (worktree setup, rebasing on main, resolving conflicts, and force-with-lease push) without product code changes.

personAuthor: jakexiaohubgithub

Git Branch Maintenance

Overview

Deterministic workflow for branch maintenance tasks: prepare a dedicated worktree, rebase onto main, resolve conflicts safely, and push updated history.

Related Skills

  • commit-conventions for commit message/split rules when commits are required.
  • review-verification-before-completion for evidence-first completion reporting.

When to Use

  • Requests like: "rebase this branch", "sync branch with main", "resolve rebase conflicts", "force-push updated branch", "do this in a worktree".
  • Task is operational Git maintenance, not feature implementation.

Workflow

  1. Preflight.
  • Confirm current repo and branch targets.
  • Verify local state with git status --short and git branch --show-current.
  • If unrelated dirty changes block operation, stop and ask before touching them.
  1. Worktree setup (preferred).
  • Fetch refs: git fetch --all --prune.
  • Create/enter dedicated worktree for target branch.
  • If branch exists locally/remotely, check out tracking branch there.
  1. Rebase sequence.
  • Update main ref: git fetch origin main.
  • Rebase target: git rebase origin/main.
  • Never use interactive rebase unless explicitly requested.
  1. Conflict handling.
  • Inspect conflicted files: git status --short.
  • Resolve only conflict markers and intended branch deltas.
  • Continue with git add <files> + git rebase --continue.
  • If conflict is ambiguous or crosses unrelated local work, stop and ask for direction.
  1. Push safety.
  • Push rewritten history with git push --force-with-lease.
  • Never use plain --force.
  1. Verification + report.
  • Confirm branch tip and remote update (git rev-parse --short HEAD, push output).
  • State whether tests were run. For Git-only maintenance, default: no tests unless requested.
  • Report exact branch, worktree path, conflict files, and old->new commit range when available.

Guardrails

  • No destructive commands (git reset --hard, git checkout --) unless explicitly requested.
  • Keep operations non-interactive.
  • Do not modify product files beyond conflict resolution required for the rebase.