AgentSkillsCN

git-rebase-workflow

在整合前,采用安全的变基实践来线性化本地分支历史的专业化工作流。当 Git 历史、分支管理、同步或恢复工作流是核心关注点时,可选用此流程;但请勿将其用于 CI 工作流设计或应用行为的实现。

SKILL.md
--- frontmatter
name: git-rebase-workflow
description: "Specialized workflow for linearizing local branch history with safe rebase practices before integration. Use when Git history, branching, synchronization, or recovery workflows are the core concern; do not use for CI workflow design or application behavior implementation."

Git Rebase Workflow

Trigger Boundary

  • Use only when local feature branch history needs cleanup before PR creation.
  • Do not use once a PR is open; use git-pr-sync-workflow.
  • Do not use on shared protected branches.

Goal

Keep local branch history coherent and review-ready without losing change intent.

Shared Git Contract (Canonical)

  • Use ../git-branch-strategy/references/git-governance-contract.md as the single schema and gate source.
  • Track rebase artifacts with GIT-RBS-* IDs.
  • Run machine validation: python3 ../git-branch-strategy/scripts/validate_git_contract.py --manifest <path/to/manifest.json>.

Inputs

  • Current branch divergence from target base branch
  • Team policy for force-push and rewritten history
  • PR status and branch sharing status

Outputs

  • GIT-RBS-* rebased branch execution record
  • Conflict resolution notes for rewritten commits
  • Push plan aligned with rewrite policy

Workflow

  1. Verify the branch is unshared and checks.pr_opened=false.
  2. Fetch latest target branch and inspect divergence.
  3. Rebase feature commits onto target base in logical order.
  4. Resolve conflicts commit-by-commit with behavioral verification.
  5. Run tests, then push with approved force-with-lease policy.

Quality Gates

  • Rebased commits preserve original behavioral intent.
  • Conflict resolutions are verified with tests.
  • checks.pr_opened=false and checks.rebase_used=true are satisfied.
  • History rewrite complies with team policy and branch protections.

Failure Handling

  • Stop when a PR is already open for the branch.
  • Stop when rebase would rewrite shared protected history.
  • Escalate when rewrite policy exceptions are requested.