本文以 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必读技术书籍

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

手把手教你把 Git 子模块更新到主项目的更多相关文章

  1. 手把手教你用git和SourceTree上传项目到github细解(转)

    尊重原创:https://blog.csdn.net/qq_32365567/article/details/52859166 一.引言 我想大家现在都很熟悉github了,也能运用github上开源 ...

  2. 手把手教你使用Git管理你的软件代码

    什么是分布式版本控制系统?Git有哪些常用命令?什么是仓库?Git的操作区域包括哪些?Git有哪些常用对象(object)?git rebase和git merge的区别是什么?git reset,g ...

  3. 推荐!手把手教你使用Git

    推荐!手把手教你使用Git 原文出处: 涂根华的博客   http://blog.jobbole.com/78960/ 一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. 二:SVN与 ...

  4. 【转载】手把手教你使用Git(简单,实用)

    手把手教你使用Git(简单,实用) 标签: git 2016年04月21日 20:51:45 1328人阅读 评论(0) 收藏 举报 一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. ...

  5. 手把手教你如何使用Cocos2d Console 进行html5项目发布

    手把手教你如何使用Cocos2d Console 进行html5项目发布   1.首先需要先安装Cocos2d Console运行需要的工具. 详情参见 这篇文章 http://www.cocoach ...

  6. 转:手把手教你如何玩转Solr(包含项目实战)

    原文地址:手把手教你如何玩转Solr(包含项目实战) 参考原文

  7. 手把手教你使用Git

    一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. 二:SVN与Git的最主要的区别? SVN是集中式版本控制系统,版本库是集中放在中央服务器的,而干活的时候,用的都是自己的电脑,所以 ...

  8. Git之 手把手教你使用Git

    一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. 二:SVN与Git的最主要的区别? SVN是集中式版本控制系统,版本库是集中放在中央服务器的,而干活的时候,用的都是自己的电脑,所以 ...

  9. 《转》手把手教你使用Git

    Git是分布式版本控制系统,那么它就没有中央服务器的,每个人的电脑就是一个完整的版本库,这样,工作的时候就不 需要联网了,因为版本都是在自己的电脑上.既然每个人的电脑都有一个完整的版本库,那多个人如何 ...

随机推荐

  1. 展示html/javascript/css------Live-Server服务器

    Live-server简介 这是一款带有热加载功能的小型开发服务器.用它来展示你的HTML / JavaScript / CSS,但不能用于部署最终的网站. 官网地址:https://www.npmj ...

  2. 2月10日 体温APP开发总结

    1.Java代码 1.user package bean;public class User { private String name; private String riqi; private S ...

  3. 【刷题-LeetCode】153 Find Minimum in Rotated Sorted Array

    Find Minimum in Rotated Sorted Array Suppose an array sorted in ascending order is rotated at some p ...

  4. 【记录一个问题】linux+opencv+cuvid解码1080P视频,当使用CUDA核函数的时候,必然崩溃

    崩溃的信息如下: 1 OpenCV(4.1.0-dev) Error: Gpu API call (invalid configuration argument) in videoDecPostPro ...

  5. 申请Namecheap的.me 顶级域名以及申请ssl认证--github教育礼包之namecheap

    关于教育礼包的取得见另一篇随笔,在那里笔者申请了digital ocean的vps(虚拟专用主机),跟阿里云差不多,不过个人感觉比阿里云便宜好用一点. 有了自己的主机ip,就想到申请域名,方便好记,也 ...

  6. 实习之bii--总体感受体验

    在bii实习了一个暑假,感受收获都不少,记录一下. 首先当时面试时其实说的比较多的是sdn,结果来了以后主要在搞DNS,介绍一下所做的工作为何吧.bii名为北京下一代互联网工程中心,由于IPV6的逐渐 ...

  7. 开发者的瑞士军刀「GitHub 热点速览 v.22.04」

    Swiss Army knife 可以说是本周的关键词了,多个项目采用该词来描述它的特性:像是能全方位解决浏览器"网络"操作的 CyberChef 方便你进行数据加密.解编码,还有 ...

  8. 在 K8S 中快速部署 Redis Cluster & Redisinsight

    Redis Cluster 部署 使用 Bitnami helm chart 在 K8S redis 命名空间中一键部署 Redis cluster . helm repo add bitnami h ...

  9. centos7 service iptables save 报错

    解决办法: 1.systemctl stop firewalld 2.yum install iptables-services 3.systemctl  restart iptables 4.ser ...

  10. linux如何复制文件

    目录 一:复制文件 二:文件详细属性 一:复制文件 copy的缩写cp. 格式: cp [参数] [被复制文件的路径] [复制到的新路径] 参数: -r : 递归复制 -a : 保证某些属性不变 案列 ...