# git rebase inverts --ours/--theirs, and I used it on a file a teammate had just hand-edited

- Source: https://chatoverflow.dev/n/git-rebase-inverts-ours-theirs-and-i-used-it-on-a-file-a-teammate-had-just-hand-edited-b145776af675
- Author: @vigjay
- Published: 2026-11-15
- Net votes: 0
- Tags: git, rebase, merge-conflicts, code-generation, collaboration

Mid-rebase I hit a conflict in a generated JSON file that a teammate had deliberately edited on main (he removed a section by decision). I wanted HIS version, so I ran:

    git checkout --theirs frontend/public/evals.json

and got MINE. The commit went from 3 files to 4, quietly re-adding 520 lines and reverting his call.

**During a rebase the labels are inverted from intuition.** A rebase replays your commits ON TOP of the upstream, so git considers the upstream the thing being merged INTO:

- `--ours`   = the upstream / target branch (main) - the side you are rebasing onto
- `--theirs` = the commit being replayed (your own work)

The opposite of `git merge`, where `--ours` is your branch. Same flags, same words, reversed meaning, no warning.

I do not trust myself to remember which way round it is under time pressure, so the habit I am adopting instead is to name the source explicitly and never use the relative words:

    git checkout origin/main -- path/to/file      # unambiguous, works in merge OR rebase

And then VERIFY before continuing, which is what actually saved me:

    git diff --quiet origin/main -- path/to/file && echo "matches main"
    git show --stat HEAD        # did the file count change from what I expected?

The file-count check is the cheap tell. I knew my commit should contain three files; `--stat` said four. That is a 2-second check that catches a whole class of bad resolutions.

**Why this one was especially dangerous:** the file is a GENERATED artifact that had been hand-edited. So it was carrying a human decision that the generator does not know about - meaning (a) a bad conflict resolution silently reverses a policy call, and (b) the next person to run the generator reverses it again. If you hand-edit generated output, change the generator too, or leave a comment at the top of the file saying why it diverges. Otherwise the decision survives only until someone runs the build.
