Git Rebase Ours vs Theirs

Published
Length
3 min read

Luis Felipe Dias

All posts

In git rebase ours vs theirs, the two options pick which branch wins a conflict. During a rebase, ours means the target base branch, while theirs means your feature branch. This role flip trips up many developers every day. In a standard merge, ours is your current feature branch. Rebase works the other way around. Git rewinds your branch to the target base branch first. Then it plays your feature commits back one at a time. How git rebase ours vs theirs works under the hood To grasp git reb

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

In git rebase ours vs theirs, the two options pick which branch wins a conflict. During a rebase, ours means the target base branch, while theirs means your feature branch.

This role flip trips up many developers every day. In a standard merge, ours is your current feature branch. Rebase works the other way around. Git rewinds your branch to the target base branch first. Then it plays your feature commits back one at a time.

How git rebase ours vs theirs works under the hood

To grasp git rebase ours vs theirs, look at how Git moves the head pointer. When you start a rebase, Git checks out the upstream base branch first. Because Git sits on that base branch now, that base branch becomes ours.

Next, Git takes each commit from your feature branch and applies it on top. Because those commits come in from outside the current checkout, your work becomes theirs. This is the exact opposite of a standard merge workflow.

During a standard merge, you stay on your feature branch the whole time. You pull the other branch into your current work. So in a merge, ours is your feature work, and theirs is the upstream code.

Teams use rebase to keep project history clean and linear. When conflicts pop up, you can tell Git to favor one side. Picking the ours option keeps the upstream base code when lines clash. Picking the theirs option keeps the changes from your feature branch commits.

When to choose each option in your workflow

Choosing between the two sides depends on which code holds the truth. Teams choose ours during a rebase when upstream changes must win. For example, a main branch might have a critical fix or a shared file update. If your local feature branch touched the same lines by mistake, pick ours.

Git Commit Signing (GPG, SSH) + K8s RBAC Role vs ClusterRole: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Teams choose theirs during a rebase when the feature branch holds the right logic. Suppose you rewrote a module and upstream made a minor text edit there. You want your new module logic to replace the old base code. In that rebase conflict, you choose theirs to keep your feature work.

Be careful with strategy options that auto-resolve every conflict across a whole file. Auto-picking one side can drop needed lines from the other branch without warning. Most teams inspect each conflict block by hand before they pick a winner. Good code review habits catch mistakes before a branch merges into main.

Tradeoffs of automated conflict resolution and team controls

Fast conflict resolution helps developers ship code on time. Yet blind use of ours or theirs can wipe out important logic or security checks. If a developer picks theirs across a shared file, an upstream patch might vanish.

Static git rules and branch checks help stop bad merges in code hosts. Teams set up branch protection so every rebase needs a clean test run. They also require peer reviews before anyone merges code into production branches.

Still, git rules only govern source files before deployment. Once code runs or engineers touch live systems, git history cannot guard live data. Teams pair strong git habits with runtime controls for database and server tasks.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Why are ours and theirs reversed in a git rebase?

Git rebase switches to the target base branch before it replays your feature commits. Because Git sits on the base branch first, that base branch becomes ours. Your own feature commits get applied on top, so Git calls them theirs.

How do I keep my feature branch changes during a rebase conflict?

To keep your feature branch changes during a rebase conflict, select the theirs side. In a rebase, your feature commits are the incoming changes being replayed. Choosing theirs tells Git to use your feature commit over the base branch.

Is it safe to resolve all rebase conflicts with one strategy option?

Using a single strategy option across a whole rebase is risky for complex files. It forces every conflict block to pick one side and drops the other changes. Inspect conflicts file by file unless you want to overwrite one side.

The query runs. The emails stay hidden.