需求描述:
公司小明想在远程的A.git项目的a分支基础上新建一个B.git项目,在B.git项目上可以看到A.git项目的a分支的所有提交记录。
方法步骤:
1)查看A项目分支,我这里以BCOS项目的3.0.5分支为例,如下:
-
chenfm@4438fad59b85:~/BCOS$ git branch -a
-
3.0.3
-
3.0.4
-
* 3.0.5
-
3.0.6
-
GW200-2018120519-Release
-
devel-2.6
-
master
-
remotes/origin/3.0.1
-
remotes/origin/3.0.2
-
remotes/origin/3.0.3
-
remotes/origin/3.0.4
-
remotes/origin/3.0.5
-
remotes/origin/3.0.6
2)查看3.0.5分支的提交记录,用于后面对照:
-
chenfm@4438fad59b85:~/BCOS$ git log
-
commit 952ecbf89bf2040ea4282c14f20e2999e70c96b1
-
Author: chenfm <chenfanming@ruijie.com.cn>
-
Date: Wed Jan 30 10:36:53 2019 +0800
-
-
<E5><BA><94><E7><94><A8><E6><B5><81><E9><87><8F><E3><80><81><E7><94><A8><E6><88><B7><E6><B5><81><E9><87><8F><E9><80><9F><E7><8E>
-
-
commit d0ffc016bd80098a720719808e6006e4e77ae513
-
Author: chenfm <chenfanming@ruijie.com.cn>
-
Date: Tue Jan 29 16:09:05 2019 +0800
-
-
<E6><98><93><E7><94><A8><E6><80><A7><E6><94><B9><E8><BF><9B>bug<EF><BC><9A>1225<EF><BC><8C><E7><BA><BF><E8><B7><AF><E6><B5><81>
-
-
commit ff6636de3c81c0e131313830adcf1271d5baa187
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Fri Jan 25 17:41:06 2019 +0800
-
-
fixed snmp v3 get index Maybe no result.
-
-
commit 8879b89ff646d3e6fb9b74a9e14a48200457ef68
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Fri Jan 25 11:11:20 2019 +0800
-
-
fixed weixin scan can't jump
-
-
commit 97c3300f0cca59b7aa0b3facebe9bacc516ddbd5
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Thu Jan 24 18:43:44 2019 +0800
-
-
fixed snmp v3 support
-
-
commit b7e472460f3654edbc84069d018844e7050fa649
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Thu Jan 24 09:47:03 2019 +0800
-
-
fixed snmp can't create cache for webauth
-
-
commit ef971d8793170e330762880d6348095edb60ec3e
-
Author: chenfm <chenfanming@ruijie.com.cn>
-
Date: Thu Jan 17 17:24:22 2019 +0800
3)创建B项目,创建过程我这边不做描述,我这里以我已经创建好的test项目为例新建1.0分支
-
chenfm@4438fad59b85:~/devel/identify/test$ git branch -a
-
* master
-
remotes/origin/HEAD -> origin/master
-
remotes/origin/master
4)在B项目添加A项目分支信息
-
chenfm@4438fad59b85:~/devel/identify/test$ git branch -a //下面只有master分支
-
* master
-
remotes/origin/HEAD -> origin/master
-
remotes/origin/master
-
chenfm@4438fad59b85:~/devel/identify/test$ git remote add -f BCOS /home/chenfm/BCOS //(BCOS为A项目名称,/home/chenfm/BCOS为A项目路径)
-
Updating BCOS
-
warning: no common commits
-
remote: Counting objects: 21542, done.
-
remote: Compressing objects: 100% (14824/14824), done.
-
remote: Total 21542 (delta 4955), reused 20476 (delta 4352)
-
Receiving objects: 100% (21542/21542), 20.24 MiB | 22.64 MiB/s, done.
-
Resolving deltas: 100% (4955/4955), done.
-
From /home/chenfm/BCOS
-
* [new branch] 3.0.3 -> BCOS/3.0.3
-
* [new branch] 3.0.4 -> BCOS/3.0.4
-
* [new branch] 3.0.5 -> BCOS/3.0.5
-
* [new branch] 3.0.6 -> BCOS/3.0.6
-
* [new branch] GW200-2018120519-Release -> BCOS/GW200-2018120519-Release
-
* [new branch] devel-2.6 -> BCOS/devel-2.6
-
* [new branch] master -> BCOS/master
-
chenfm@4438fad59b85:~/devel/identify/test$ git branch -a //再次查看B项目分支,发现多出了A项目的分支
-
* master
-
remotes/BCOS/3.0.3
-
remotes/BCOS/3.0.4
-
remotes/BCOS/3.0.5
-
remotes/BCOS/3.0.6
-
remotes/BCOS/GW200-2018120519-Release
-
remotes/BCOS/devel-2.6
-
remotes/BCOS/master
-
remotes/origin/HEAD -> origin/master
-
remotes/origin/master
-
chenfm@4438fad59b85:~/devel/identify/test$
5)在B项目上创建1.0分支
-
chenfm@4438fad59b85:~/devel/identify/test$ git checkout -b 1.0 BCOS/3.0.5 //1.0为要新建的分支,BCOS/3.0.5为基础分支
-
Branch 1.0 set up to track remote branch 3.0.5 from BCOS.
-
Switched to a new branch '1.0'
-
chenfm@4438fad59b85:~/devel/identify/test$ git branch -a //这个时候1.0还只是在本地
-
* 1.0
-
master
-
remotes/BCOS/3.0.3
-
remotes/BCOS/3.0.4
-
remotes/BCOS/3.0.5
-
remotes/BCOS/3.0.6
-
remotes/BCOS/GW200-2018120519-Release
-
remotes/BCOS/devel-2.6
-
remotes/BCOS/master
-
remotes/origin/HEAD -> origin/master
-
remotes/origin/master
-
chenfm@4438fad59b85:~/devel/identify/test$ git push origin 1.0 //提交1.0分支到远程仓库
-
Counting objects: 21382, done.
-
Delta compression using up to 24 threads.
-
Compressing objects: 100% (14207/14207), done.
-
Writing objects: 100% (21381/21381), 20.22 MiB | 2.03 MiB/s, done.
-
Total 21381 (delta 4857), reused 21332 (delta 4818)
-
remote: Resolving deltas: 100% (4857/4857), done.
-
To git@git.dev.tencent.com:cfm5538/test.git
-
* [new branch] 1.0 -> 1.0
-
chenfm@4438fad59b85:~/devel/identify/test$ git branch -a //这个时候在B项目就可以看到1.0分支了
-
* 1.0
-
master
-
remotes/BCOS/3.0.3
-
remotes/BCOS/3.0.4
-
remotes/BCOS/3.0.5
-
remotes/BCOS/3.0.6
-
remotes/BCOS/GW200-2018120519-Release
-
remotes/BCOS/devel-2.6
-
remotes/BCOS/master
-
remotes/origin/1.0 //远程仓库已经可以看到新建的分支
-
remotes/origin/HEAD -> origin/master
-
remotes/origin/master
-
chenfm@4438fad59b85:~/devel/identify/test$
6)现在我们查看一下B项目的1.0分支是否包含A项目的3.0.5分支的所有提交记录,跟步骤2对照一下
-
chenfm@4438fad59b85:~/devel/identify/test$ git log
-
commit 952ecbf89bf2040ea4282c14f20e2999e70c96b1
-
Author: chenfm <chenfanming@ruijie.com.cn>
-
Date: Wed Jan 30 10:36:53 2019 +0800
-
-
<E5><BA><94><E7><94><A8><E6><B5><81><E9><87><8F><E3><80><81><E7><94><A8><E6><88><B7><E6><B5><81><E9><87><8F><E9><80><9F><E7><8E>
-
-
commit d0ffc016bd80098a720719808e6006e4e77ae513
-
Author: chenfm <chenfanming@ruijie.com.cn>
-
Date: Tue Jan 29 16:09:05 2019 +0800
-
-
<E6><98><93><E7><94><A8><E6><80><A7><E6><94><B9><E8><BF><9B>bug<EF><BC><9A>1225<EF><BC><8C><E7><BA><BF><E8><B7><AF><E6><B5><81>
-
-
commit ff6636de3c81c0e131313830adcf1271d5baa187
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Fri Jan 25 17:41:06 2019 +0800
-
-
fixed snmp v3 get index Maybe no result.
-
-
commit 8879b89ff646d3e6fb9b74a9e14a48200457ef68
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Fri Jan 25 11:11:20 2019 +0800
-
-
fixed weixin scan can't jump
-
-
commit 97c3300f0cca59b7aa0b3facebe9bacc516ddbd5
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Thu Jan 24 18:43:44 2019 +0800
-
-
fixed snmp v3 support
-
-
commit b7e472460f3654edbc84069d018844e7050fa649
-
Author: zhuliangyou <zhuliangyou@ruijie.com.cn>
-
Date: Thu Jan 24 09:47:03 2019 +0800
-
-
fixed snmp can't create cache for webauth
end,谢谢!!!
阅读(54777) | 评论(0) | 转发(1) |