git 添加更新子模块

添加submodule到仓库

下载父仓库:

git clone git@gitlab.abc.com:cloud-security-platform/console-after.git

父仓库中添加submodule,分支可以指定对应的submodule分支,以master为例:
进入submodule所在目录:

 cd src/main/webapp/

下载submodule对应的master分支:

git submodule add -b master git@gitlab.abc.com:cs70/console-before.git console
或者(默认就是master)
git submodule add  git@gitlab.abc.com:cs70/console-before.git console

将submodule提交到本地库:

git commit -am "add submodule console"

将subodule推送到线上库:

 git push origin master

命令执行完成会发现生成了一个.gitmodules文件,可以修改该文件中代码的地址

更新submodule

更新操作跟普通的项目操作一样:
进入submodule所在目录(/src/main/webapp/console)
git pull从远程获取最新版本merge到本地
git branch -a 查看所有submodule版本
git branch -vv 查看当前head对应的远程分支
git checkout 对应分支版本
git commit -am “更改功能点说明”
git push origin “远程分支” [以master分支为例:git push origin master]

问题记录

由于第一次操作,出现了以下错误提示:

A git directory for 'console' is found locally with remote(s):
  origin        git@gitlab.abc.com:cs70/console-before.git
If you want to reuse this local git directory instead of cloning again from
  git@gitlab.abc.com:cs70/console-before.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.

解决方法:

git submodule add --name Common git@gitlab.abc.com:cs70/console-before.git console
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值