From e09aae10aa811ba00d384fc69ae8f62891df34d4 Mon Sep 17 00:00:00 2001 From: Spencer Gilbert Date: Wed, 7 Oct 2026 12:00:57 -0400 Subject: [PATCH] [skills/github] Add force pushing guidance to protect reviewed history --- skills/github/SKILL.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/skills/github/SKILL.md b/skills/github/SKILL.md index d751188..4ad75da 100644 --- a/skills/github/SKILL.md +++ b/skills/github/SKILL.md @@ -21,3 +21,18 @@ Discover specifics from the CLI: `gh --help` prints examples plus the - **Read CI with `--log-failed`**, which returns only the failed steps of a run. - **Reach for `gh api` when a subcommand stops short**, using a relative path: `gh api repos/owner/repo/pulls/55 --jq '.state, .user.login'`. `--paginate` follows `Link` headers; `-f` sends strings, `-F` typed values. - **Confirm before writing.** For comments, closes, merges, pushes, and reruns, state the exact target and body and get a yes first, especially on repositories the user does not own. + +## Force pushing + +A force push rewrites history that a reviewer may already have read, so the default is: once a PR has been reviewed, never rewrite it. + +```bash +# Check review state before rebasing, amending, or pushing --force to the PR branch +gh pr view --json reviewDecision,reviews +``` + +- **Once a human has reviewed, add commits instead of rewriting.** If `reviews` is non-empty, or `reviewDecision` is `CHANGES_REQUESTED` or `APPROVED`, push follow-up commits so the incremental diff and each anchored review comment survive. Squash at the end, or let the merge button squash. +- **An unreviewed, own-work PR is fair game.** Empty `reviews` with `REVIEW_REQUIRED` means nobody has looked yet: rebasing onto the base branch or amending is safe. +- **Ask instead of guessing** when reviews exist but the reviewer has asked for a rewrite, or when the repo requires linear history. +- **When it is authorized, `git push --force-with-lease`**, never plain `--force`: it aborts if the remote moved since your last fetch instead of silently dropping someone's commits. +- **`gh pr merge` is not a force push.** Prefer the platform's own merge/squash over rewriting the branch locally. -- 2.51.2