gpt4 book ai didi

git - 如何添加 git 子模块并将其标记到版本中?

转载 作者:行者123 更新时间:2023-12-04 02:54:50 25 4
gpt4 key购买 nike

git clone my-new-repo-url
mkdir deps
cd deps
git submodule add -b 6.2.0 https://github.com/leethomason/tinyxml2.git

产量
fatal: 'origin/6.2.0' is not a commit and a branch '6.2.0' cannot be created from it
Unable to checkout submodule 'deps/tinyxml2'

不填充 .gitmodules,但创建一个文件夹 .git/modules/deps/tinyxml2并在 deps/tinyxml2 中添加一个 repo

我以为我以前这样做过,它会用 .gitmodules 填充
[submodule "deps/tinyxml2"]
path = deps/tinyxml2
url = https://github.com/leethomason/tinyxml2.git
branch = 6.2.0

但它现在不起作用是怎么回事?

最佳答案

分支和发布标签不是一回事。一个分支可能会随着时间的推移继续发展和变化。在 .gitmodules branch = something 中有标志意味着子模块将在被要求更新时跟踪该分支。
git submodule add https://github.com/leethomason/tinyxml2.git用 .gitmodules 填充

[submodule "deps/tinyxml2"]
path = deps/tinyxml2
url = https://github.com/leethomason/tinyxml2.git

然后手动 checkout 子模块中的所需标签
cd deps/tinyxml2
git checkout 6.2.0

添加/提交/推送
git commit -am "adding and commiting all in one command"
git push

将子模块添加到repo中,在浏览器中我们可以看到

enter image description here

在哪里 c1424ee4是生成该 release-tag 的特定提交

现在做一个新的克隆到另一个文件夹
git clone my-new-repo-url
git submodule update --init --recursive

子模块是否在同一版本标签 6.2.0 处 checkout (提交 c1424ee4 )

关于git - 如何添加 git 子模块并将其标记到版本中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53525204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com