Skip to content

docs(agents): warn about reversed --ours/--theirs in rebase#602

Closed
fglock wants to merge 3 commits intomasterfrom
docs/agents-rebase-ours-theirs
Closed

docs(agents): warn about reversed --ours/--theirs in rebase#602
fglock wants to merge 3 commits intomasterfrom
docs/agents-rebase-ours-theirs

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 29, 2026

Summary

During git rebase, the meaning of --ours / --theirs is the opposite of git merge:

  • merge: --ours = the branch you're on
  • rebase: --ours = the upstream target (e.g. master), --theirs = the commit being replayed (your work)

Using git checkout --ours <file> to "keep our work" during a rebase conflict silently takes the upstream version, makes the replayed commit empty, and rebase drops it without error. This nearly cost us the cpan-reports refresh on PR #601 (recovered via reflog).

This PR adds:

  • A warning block in AGENTS.md with merge vs rebase semantics, the safe pattern (--theirs during rebase), a post-rebase verification step (git log --oneline <upstream>..HEAD), and reflog recovery instructions.
  • An incident-log row for the 2026-04-29 near-miss.

Test plan

  • Docs only; no code changes

fglock added 3 commits April 29, 2026 09:02
During rebase, `--ours` refers to the upstream target (not the branch
being rebased), which is the opposite of merge. Using `git checkout
--ours <file>` to "keep our work" during a rebase conflict silently
takes the upstream version, makes the replayed commit empty, and
rebase drops it without error.

Adds:
- A warning block with merge vs rebase semantics, the safe pattern
  (`--theirs` to keep your work during rebase), a verification step
  (`git log --oneline <upstream>..HEAD`), and reflog recovery.
- An incident-log row for the 2026-04-29 near-miss on the
  cpan-reports refresh PR.
Add the official quote from git-rebase(1) and a link to the docs so
future agents (and humans) can confirm this isn't folklore.
If a broken rebase drops your commit and you force-push the branch to
a SHA that equals master's HEAD, GitHub auto-CLOSES the PR. Pushing
the corrected SHA back does NOT reopen it — `gh pr reopen <n>` is
required. Add a verification step to check `gh pr view --json
state,files` after any force-push.

This actually happened on PR #601 during the cpan-reports refresh.
@fglock
Copy link
Copy Markdown
Owner Author

fglock commented Apr 29, 2026

Combined into PR #601.

@fglock fglock closed this Apr 29, 2026
@fglock fglock deleted the docs/agents-rebase-ours-theirs branch April 29, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant