DrizzlingCattus
DrizzlingCattus

Reputation: 68

Git: how to merge other repository's remote master branch into local master without contaminating it

I have two github repository.

One is client repo and the other is server repo.

client repo is currently in local and server repo is in remote.

I want to manage two repository into one.

How to merge two repo like below?


client repo git commits

[branch master]

client-root

[branch dev]

client-root -> 1 -> 2 -> client-HEAD


server repo git commits

[branch master]

server-root -> 3 -> 4 -> server-HEAD


what i want

[branch master]

client-root

[branch dev]

client-root -> 1 -> 2 -> client-HEAD -> server-root -> 3 -> 4 -> server-HEAD


thank you for reading!

Upvotes: 0

Views: 47

Answers (1)

Vlad274
Vlad274

Reputation: 6844

Based on the state you describe, this will create the desired state in your local (client) repo:

  1. git checkout dev - Switch to dev branch
  2. git cherry-pick ..server/master - Take all commits reachable from server/master and put them on top of the current branch

Upvotes: 1

Related Questions