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

本文涉及的产品
应用实时监控服务-应用监控,每月50GB免费额度
简介: 本文以 skywalking-rocketbot-ui子模块合并到 skywalking 为例,手把手教你如何把 Git 子模块更新到主项目中去。首先,把fork的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了。

相关实践学习
通过轻量消息队列(原MNS)主题HTTP订阅+ARMS实现自定义数据多渠道告警
本场景将自定义告警信息同时分发至多个通知渠道的需求,例如短信、电子邮件及钉钉群组等。通过采用轻量消息队列(原 MNS)的主题模型的HTTP订阅方式,并结合应用实时监控服务提供的自定义集成能力,使得您能够以简便的配置方式实现上述多渠道同步通知的功能。
相关文章
|
2月前
|
Shell 网络安全 开发工具
项目快速导入git
本文介绍了如何在本地初始化 Git 仓库并将代码提交到远程仓库(如 GitHub 或 Gitee)的基本流程。内容包括安装 Git、创建仓库、添加文件、提交更改以及推送代码到远程仓库的详细步骤,适合初学者快速掌握 Git 的基本使用方法。
124 1
|
9月前
|
开发工具 git
如何操作github,gitee,gitcode三个git平台建立镜像仓库机制,这样便于维护项目只需要维护一个平台仓库地址的即可-优雅草央千澈
如何操作github,gitee,gitcode三个git平台建立镜像仓库机制,这样便于维护项目只需要维护一个平台仓库地址的即可-优雅草央千澈
501 69
如何操作github,gitee,gitcode三个git平台建立镜像仓库机制,这样便于维护项目只需要维护一个平台仓库地址的即可-优雅草央千澈
|
8月前
|
安全 开发工具 git
git分布式版本控制系统及在码云上创建项目并pull和push
通过本文的介绍,我们详细讲解了Git的基本概念和工作流程,并展示了如何在码云上创建项目及进行pull和push操作。Git作为一种分布式版本控制系统,为开发者提供了强大的工具来管理代码变更和协作开发。希望本文能帮助您更好地理解和使用Git及码云,提高开发效率和代码质量。
291 18
|
8月前
|
安全 开发工具 git
git分布式版本控制系统及在码云上创建项目并pull和push
通过本文的介绍,我们详细讲解了Git的基本概念和工作流程,并展示了如何在码云上创建项目及进行pull和push操作。Git作为一种分布式版本控制系统,为开发者提供了强大的工具来管理代码变更和协作开发。希望本文能帮助您更好地理解和使用Git及码云,提高开发效率和代码质量。
225 16
|
Java Shell 开发工具
git集成IDEA,托管项目实现版本管理
git集成IDEA,托管项目实现版本管理
127 0
|
架构师 开发工具 git
项目去除git版本控制 去除版本控制
文章提供了去除本地项目Git版本控制的步骤,包括删除`.git`文件夹和`.idea`目录下的`vcs.xml`文件。
项目去除git版本控制 去除版本控制
|
jenkins 测试技术 开发工具
协同开发的艺术:Git 在团队项目中的高效应用
【8月更文第16天】在现代软件开发中,团队成员之间的高效协作是至关重要的。Git 作为一种分布式版本控制系统,为开发者提供了强大的工具来管理代码的变化和协作。本文将介绍如何利用 Git 来优化团队的工作流程,并提供实际操作的代码示例。
382 1
|
网络安全 开发工具 数据安全/隐私保护
Win10使用Git克隆项目出现fatal: Authentication failed for异常
Windows 10系统中使用Git克隆项目时出现"fatal: Authentication failed for"异常的解决方法,主要是通过修改凭据管理器中的Git凭据密码来解决因密码过期导致的身份验证失败问题。
718 0
Win10使用Git克隆项目出现fatal: Authentication failed for异常
|
Java 开发工具 git
【Azure 应用服务】本地Git部署Java项目到App Server,访问无效的原因
【Azure 应用服务】本地Git部署Java项目到App Server,访问无效的原因
122 0
|
开发工具 git
IDEA中怎么使用git下载项目到本地,通过URL克隆项目(giteegithub)
IDEA中怎么使用git下载项目到本地,通过URL克隆项目(giteegithub)
1087 0