Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a new branch from another repository?

I have a repository (repo1) with a master branch and another repository (repo2) with a master branch. Now I want to create a new branch in repo1 from repo2 with all commits history.


My expected result:

repo2
----
|
 \
  master


repo1
----------
|         |
 \         \
  master    master-from-repo2
like image 805
Benyamin Jafari Avatar asked Jan 13 '19 12:01

Benyamin Jafari


1 Answers

cd repo1
git fetch repo2 master:master-from-repo2

Remote branch master is fetched from repo2 into local branch master-from-repo2.

like image 185
phd Avatar answered Nov 16 '22 21:11

phd