76. Fix Repository with Unrelated Histories
Beginner Mode
Start your terminal to use beginner mode.
Scenario:
The repository at /home/interview/repo is in a broken state. Local and remote branches have diverged with no common ancestor. Consequently, git push origin main fails with a non-fast-forward error, and git pull origin main fails because the histories are unrelated.
Task:
Navigate to /home/interview/repo. Merge and linearize the unrelated histories (using rebase) to create a single commit sequence.
Example:
# Before (Broken)
$ git pull origin main
fatal: refusing to merge unrelated histories
# After (Fixed - Linear History)
$ git pull origin main
Already up to date.
$ git log --oneline --decorate
e8f9g0h (HEAD -> main, origin/main) Add local feature B
d7e8f9g Add local feature A
b5c6d7e Add remote config
a4b5c6d Remote initial commit
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Essential
Linux 0/29
AWS 0/10
Kubernetes 0/15
CI/CD 0/5
Networking 0/9
Need more practice in this area? Explore more questions →
Zscaler
Accenture
Coinbase
Adobe
EPAM
Twitch
Amazon
Kayak
Autodesk
Lyft
Revolut
RedHat
Bloomberg
Datadog
Palantir
TCS
HashiCorp
Google
DeutscheBank
GitHub
Apple
Cloudflare
Stripe
Microsoft
NVIDIA
GoDaddy
X
SAP
Spotify
Airbnb
Meta
Reddit
Yelp
Okta
Dropbox
Slack
ActivisionBlizzard
Uber
IBM
DeliveryHero
Robinhood
GitLab
Shopify
Samsung
Elastic
Twilio
Netflix
CrowdStrike
Ubisoft
Anthropic
Capital One
Splunk
Intel
AMD
Databricks