我是靠谱客的博主 害羞魔镜,最近开发中收集的这篇文章主要介绍git 在 A 项目中引用 B 项目1 添加仓库2 更新仓库参考博客git submodule: already exists in the index,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Git Submodule 可许可一个git仓库,作为另一个git仓库的子目录,保持父项目和子项目相互独立。

1 添加仓库

git submodule add <仓库地址> <本地路径>

在父仓库根目录增加了.gitmodule文件

// 添加submodule字段
[submodule "submodule1"]
url = *****.git

2 更新仓库

克隆父亲仓库(包含子目录),并不会clone下子仓库的文件,只是会克隆下.gitmodule描述文件

我们需要使用下面命令更新

// 初始化本地配置文件
$ git submodule init
// 检出父仓库列出的commit
$ git submodule update

参考博客

git中submodule子模块的添加、使用和删除
https://blog.csdn.net/guotianqing/article/details/82391665

git submodule: already exists in the index

在 github 上面 clone 一个包含有 submodule 的 repo 的时候,用如下命令更新 submodule:
git submodule update --remote --merge

一直没法更新,尝试重新 add submodule,比如:

git submodule add https://github.com/cisco/openh264 open_source_code/openh264

一直报如下错误:
‘open_source_code/openh264’ already exists in the index

执行如下命令,解决此问题:

git rm -r --cached open_source_code/openh264

最后

以上就是害羞魔镜为你收集整理的git 在 A 项目中引用 B 项目1 添加仓库2 更新仓库参考博客git submodule: already exists in the index的全部内容,希望文章能够帮你解决git 在 A 项目中引用 B 项目1 添加仓库2 更新仓库参考博客git submodule: already exists in the index所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(81)

评论列表共有 0 条评论

立即
投稿
返回
顶部