ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

手把手教你把 Git 子模块更新到主项目

2022-02-23 09:02:37  阅读:176  来源: 互联网

标签:code Git protocol OneMore 手把手 git master 模块 skywalking


本文以 skywalking-rocketbot-ui子模块合并到 skywalking 为例,手把手教你如何把 Git 子模块更新到主项目中去。

首先,把fork的skywalking项目克隆到本地:

OneMore MINGW64 /d/code
$ git clone https://github.com/heihaozi/skywalking.git skywalking
Cloning into 'skywalking'...
remote: Enumerating objects: 241687, done.
remote: Counting objects: 100% (373/373), done.
remote: Compressing objects: 100% (201/201), done.
remote: Total 241687 (delta 64), reused 240 (delta 21), pack-reused 241314
Receiving objects: 100% (241687/241687), 156.98 MiB | 3.83 MiB/s, done.
Resolving deltas: 100% (93272/93272), done.
Updating files: 100% (5928/5928), done.

进入skywalking目录,设置用户名和邮箱:

OneMore MINGW64  /d/code
$ cd skywalking/

OneMore MINGW64  /d/code/skywalking (master)
$ git config user.name CharliePu

OneMore MINGW64  /d/code/skywalking (master)
$ git config user.email heihaozi2006@163.com

指定将与复刻同步的远程上游仓库:

OneMore MINGW64  /d/code/skywalking (master)
$ git remote add upstream https://github.com/apache/skywalking.git

查看一下远程上游仓库是否生效:

OneMore MINGW64  /d/code/skywalking (master)
$ git remote -v
origin  https://github.com/heihaozi/skywalking.git (fetch)
origin  https://github.com/heihaozi/skywalking.git (push)
upstream        https://github.com/apache/skywalking.git (fetch)
upstream        https://github.com/apache/skywalking.git (push)

没有问题,初始化本地子模块:

OneMore MINGW64  /d/code/skywalking (master)
$ git submodule init
Submodule 'apm-protocol/apm-network/src/main/proto' (https://github.com/apache/skywalking-data-collect-protocol.git) registered for path 'apm-protocol/apm-network/src/main/proto'
Submodule 'oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol' (https://github.com/apache/skywalking-query-protocol.git) registered for path 'oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol'
Submodule 'skywalking-ui' (https://github.com/apache/skywalking-rocketbot-ui.git) registered for path 'skywalking-ui'
Submodule 'test/e2e/e2e-protocol/src/main/proto' (https://github.com/apache/skywalking-data-collect-protocol.git) registered for path 'test/e2e/e2e-protocol/src/main/proto'

从子模块的远端更新修改:

OneMore MINGW64  /d/code/skywalking (master)
$ git submodule update
Cloning into 'D:/code/skywalking/apm-protocol/apm-network/src/main/proto'...
Cloning into 'D:/code/skywalking/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol'...
Cloning into 'D:/code/skywalking/skywalking-ui'...
Cloning into 'D:/code/skywalking/test/e2e/e2e-protocol/src/main/proto'...
Submodule path 'apm-protocol/apm-network/src/main/proto': checked out 'e626ee04850703c220f64b642d2893fa65572943'
Submodule path 'oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol': checked out '47202fc1eaa1864c587a78f423a0685ffbe294ad'
Submodule path 'skywalking-ui': checked out '9e56d6cbbaff4678751f5355b953db3bbfd99c9b'
Submodule path 'test/e2e/e2e-protocol/src/main/proto': checked out 'e626ee04850703c220f64b642d2893fa65572943'

从子模块的远端拉取上游的修改:

OneMore MINGW64  /d/code/skywalking (master)
$ git submodule update --remote
Submodule path 'skywalking-ui': checked out '774b69dd84e305be975e4c5ffc0d433aa8cbda32'

检查当前文件状态:

OneMore MINGW64  /d/code/skywalking (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   skywalking-ui (new commits)

no changes added to commit (use "git add" and/or "git commit -a")

发现skywalking-ui已经有更新了,可以直接将其提交到远端,也可以修改其他文件一起提交。

这里先修改一下CHANGES.md文件,然后一起提交:

OneMore MINGW64  /d/code/skywalking (master)
$ git add skywalking-ui

OneMore MINGW64  /d/code/skywalking (master)
$ git add CHANGES.md

OneMore MINGW64  /d/code/skywalking (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   CHANGES.md
        modified:   skywalking-ui


OneMore MINGW64  /d/code/skywalking (master)
$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 409 bytes | 409.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/heihaozi/skywalking.git
   50688c187..e4a61f183  master -> master

至此,大功告成,可以向社区提交PR了。

微信公众号:万猫学社

微信扫描二维码

关注后回复「电子书」

获取12本Java必读技术书籍

最后,感谢你的点赞关注,帅气又美丽。

标签:code,Git,protocol,OneMore,手把手,git,master,模块,skywalking
来源: https://www.cnblogs.com/heihaozi/p/15925819.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有