75. Merge Repositories Preserving Both Histories
Beginner Mode
Start your terminal to use beginner mode.
Scenario:
You have two separate Git repositories at /home/interview/repo-a (5 commits) and /home/interview/repo-b (4 commits) developed independently. Create a new monorepo at /home/interview/monorepo that combines both repositories into separate subdirectories using subtree (project-a/ and project-b/) while preserving the full commit history from both repositories.
Example:
# Before (two separate repositories)
$ cd /home/interview/repo-a && git log --oneline | wc -l
5
$ cd /home/interview/repo-b && git log --oneline | wc -l
4
# After (combined monorepo with both histories)
$ cd /home/interview/monorepo && ls -la
project-a/ project-b/ .git/
$ git log --all --oneline | wc -l
12
$ find project-a/ -type f | wc -l
2
$ find project-b/ -type f | wc -l
2
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