Git
rebase
conflict resolution
merge strategies
version control

How to get their changes in the middle of conflicting Git rebase?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

During a conflicting Git rebase, “their changes” and “our changes” can be confusing because labels depend on operation context. In a rebase conflict, --ours usually refers to the branch you are rebasing onto, while --theirs refers to the commit being replayed. Developers expecting merge-style semantics often pick the wrong side and accidentally discard intended edits. The safest workflow is to inspect conflict stages, choose sides intentionally per file or hunk, and verify before continuing rebase.

Core Sections

1. Understand conflict side semantics in rebase

In rebase, Git replays your commits onto upstream. For a conflicted file:

  • ours = current upstream state (new base)
  • theirs = patch from your rebased commit being applied

This is opposite of what some expect from merge mental models.

2. Get “their” version for a file

bash
git checkout --theirs path/to/file
git add path/to/file
git rebase --continue

Use this only after confirming theirs is the side you want in current operation context.

3. Inspect stages explicitly

bash
git ls-files -u

This shows index stages and helps verify which blob corresponds to each side. For deeper inspection:

bash
1git show :2:path/to/file
2# stage 2 (ours)
3
4git show :3:path/to/file
5# stage 3 (theirs)

4. Use mergetool or partial resolution

Often you need both sides. Use merge tools or manual edits to combine hunks, then:

bash
git add path/to/file
git rebase --continue

Do not default to one side globally when conflict is nuanced.

5. Abort and retry safely when unsure

bash
git rebase --abort

If resolution direction becomes unclear, abort, create backup branch, and retry with clearer strategy.

6. Team workflow safeguards

Before large rebases:

  • create temporary safety branch
  • enable rerere for repeated conflicts
  • communicate force-push implications

This reduces risk of lost work and coordination issues.

Validation and production readiness

A reliable implementation is not complete until it is validated under realistic conditions. Add a minimal but representative test matrix that includes normal inputs, edge cases, and malformed data. For UI-focused topics, include at least one scenario for lifecycle or timing behavior (initial load, state transition, and cleanup) so regressions are detected when framework versions change. For infrastructure and tooling topics, run commands against a disposable environment before applying in production and capture expected outputs in documentation. This reduces ambiguity when teammates reproduce steps later.

Instrumentation is equally important. Add structured logs around the critical path, including input shape, selected branch decisions, and failure reasons. Keep logs concise and machine-parseable so alerts and dashboards can surface patterns quickly. If operations are expensive or remote (network, filesystem, container orchestration), include timeout handling and explicit retry policy with backoff. Silent retries without bounds are a common source of hidden incidents.

Finally, document assumptions and compatibility boundaries near the code or article examples: runtime versions, platform requirements, and known behavior differences across environments. Add a lightweight checklist for rollouts that covers dependency pinning, backup/rollback strategy, and smoke checks after deployment. Teams that treat these steps as part of the baseline implementation, not optional polish, usually see fewer production surprises and faster recovery when issues occur.

Common Pitfalls

  • Assuming rebase ours/theirs semantics are identical to merge intuition.
  • Accepting one side for all files without reviewing conflict intent.
  • Forgetting to inspect stage blobs before side selection.
  • Continuing rebase with unresolved markers still in files.
  • Skipping safety branch creation before destructive history rewrites.

Summary

To get “their changes” mid-rebase conflict, use git checkout --theirs carefully with rebase-specific semantics in mind. Validate sides with index stages, resolve selectively, and continue only after review. A cautious conflict workflow prevents accidental code loss during history rewriting.


Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.