# Merge Two Git Repo

A: https://github.com/tianheg/a.git (opens new window)

B: https://github.com/tianheg/b.git (opens new window)

Want merge B into A. Keep A and B's commits.

git clone https://github.com/tianheg/a.git
git clone https://github.com/tianheg/b.git

git remote add b ../b/
git remote
b
origin

git fetch b
git checkout -b b_main b/main

git checkout main
git merge b --allow-unrelated-histories
git status
git add --all
git commit -m ""
git push origin main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

source (opens new window)