(一)如何添加子依赖项目
从github上下载下来的文件,例如,
https://github.com/CloudCompare/CloudCompare/archive/refs/tags/v2.12.0.tar.gz
里面明明是有一个在.gitmodules文件的,内容如下,
[submodule "plugins/core/IO/qE57IO/extern/libE57Format"]
path = plugins/core/IO/qE57IO/extern/libE57Format
url = https://github.com/asmaloney/libE57Format
[submodule "extern/CCCoreLib"]
path = libs/qCC_db/extern/CCCoreLib
url = https://github.com/CloudCompare/CCCoreLib
[submodule "plugins/core/Standard/qPoissonRecon/extern/PoissonRecon"]
path = plugins/core/Standard/qPoissonRecon/extern/PoissonRecon
url = https://github.com/cloudcompare/PoissonRecon
[submodule "plugins/core/Standard/qMPlane"]
path = plugins/core/Standard/qMPlane
url = https://github.com/hvs-ait/mplane-plugin
[submodule "plugins/core/Standard/qColorimetricSegmenter"]
path = plugins/core/Standard/qColorimetricSegmenter
url = https://gitlab.univ-nantes.fr/E164955Z/ptrans
[submodule "plugins/core/Standard/qMasonry"]
path = plugins/core/Standard/qMasonry
url = https://github.com/CyberbuildLab/masonry-cc
[submodule "plugins/core/Standard/qJSonRPCPlugin"]
path = plugins/core/Standard/qJSonRPCPlugin
url = https://gitlab.com/theadib/JSonRPCPlugin.git
[submodule "plugins/core/Standard/qCanupo/contrib/dlib"]
path = plugins/core/Standard/qCanupo/contrib/dlib
url = https://github.com/davisking/dlib.git
可是,当你希望通过下面的指令克隆这些子项目依赖项时,会发现根本就没有反应【1】。
办法(1)当然你可以手动一个个去添加,不过这会非常麻烦。
办法(2)使用分支,
> git clone -b v2.12.0 --recursive https://github.com/CloudCompare/CloudCompare.git CC2120b
这里命名CC2120b是拷贝下来后重新命名的文件夹名称。
但这有个问题,有些项目是没有子分支的,或者,某些项目已经被删除了,git命令没办法找到github上的origin项目。
办法(3)使用脚本(具体可参考资料【1】)
假设你的项目解压后在CC2120b文件夹内,那就在这个文件夹内建一个脚本script.sh,然后在git bash中运行这些脚本就好了(使用命令:sh script.sh),
如果需要逐个克隆并回复y:
#!/bin/bash
set -e
rm -rf .git
git init
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' > tempfile
while read -u 3 path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
read -p "Are you sure you want to delete $path and re-initialize as a new submodule? " yn
case $yn in
[Yy]* ) rm -rf $path; git submodule add $url $path; echo "$path has been initialized";;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done 3
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?