Wur*_*rmD 3 git git-submodules
git clone my-new-repo-url
mkdir deps
cd deps
git submodule add -b 6.2.0 https://github.com/leethomason/tinyxml2.git
Run Code Online (Sandbox Code Playgroud)
产量
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'
Run Code Online (Sandbox Code Playgroud)
不填充 .gitmodules,而是创建一个文件夹.git/modules/deps/tinyxml2并在其中添加一个 repodeps/tinyxml2
我以为我以前这样做过,它会填充 .gitmodules
[submodule "deps/tinyxml2"]
path = deps/tinyxml2
url = https://github.com/leethomason/tinyxml2.git
branch = 6.2.0
Run Code Online (Sandbox Code Playgroud)
但它现在不起作用怎么办?
分支和发布标签不是一回事。一个分支可能会随着时间的推移而继续发展和改变。在 .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
Run Code Online (Sandbox Code Playgroud)
然后手动检查子模块中所需的标签
cd deps/tinyxml2
git checkout 6.2.0
Run Code Online (Sandbox Code Playgroud)
添加/提交/推送
git commit -am "adding and commiting all in one command"
git push
Run Code Online (Sandbox Code Playgroud)
将子模块添加到repo中,在浏览器中我们可以看到
这里c1424ee4是具体提交那里已生成的版本标签
现在做一个新的克隆到另一个文件夹
git clone my-new-repo-url
git submodule update --init --recursive
Run Code Online (Sandbox Code Playgroud)
是否在相同的发布标记 6.2.0 处签出子模块(提交c1424ee4)