# 1、将repo1作为远程仓库,添加到repo2中,设置别名为other[jot@myhost repo2]$ git remote add other ../repo1/
1
2
3
4
5
6
7
8
# 2、从repo1仓库中抓取数据到本仓库[jot@myhost repo2]$ git fetch other
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3(delta 0), reused 0(delta 0)
Unpacking objects: 100%(3/3), done.
From ../repo1
*[new branch] master -> other/master
1
2
3
4
# 3、将repo1仓库抓去的master分支作为新分支checkout到本地,新分支名设定为repo1[jot@myhost repo2]$ git checkout-b repo1 other/master
Branch repo1 set up to track remote branch master from other.
Switched to a new branch 'repo1'
1
2
3
# 4、切换回repo2的master分支[jot@myhost repo2]$ git checkout master
Switched to branch 'master'