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.
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
Use this only after confirming theirs is the side you want in current operation context.
3. Inspect stages explicitly
This shows index stages and helps verify which blob corresponds to each side. For deeper inspection:
4. Use mergetool or partial resolution
Often you need both sides. Use merge tools or manual edits to combine hunks, then:
Do not default to one side globally when conflict is nuanced.
5. Abort and retry safely when unsure
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/theirssemantics 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
- How to git-pull a given patch set from Gerrit?
- How to git-svn clone the last n revisions from a Subversion repository?
- How to git diff the working tree to the stash?
- How to git merge without creating a merge commit?
- How to git pull from master into the development branch
- How to git pull from master into the development branch
- How to 'git pull' without switching branches git checkout?
- How to git rebase a branch with the onto command?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.