从特定的 repo 哈希或标签创建一个 git 子模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18755933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:03:26  来源:igfitidea点击:

Create a git submodule from a specific repo hash or tag

gittwitter-bootstrapgit-submodules

提问by ColinE

I have a project which depends on Twitter bootstrap 2.x, however, when I add bootstrap as a submodule using the following:

我有一个依赖于 Twitter bootstrap 2.x 的项目,但是,当我使用以下命令将 bootstrap 添加为子模块时:

git submodule add https://github.com/twbs/bootstrap.git

This brings in the latest version of bootstrap.

这带来了最新版本的引导程序。

I would like to create a submodule for a specific tag, but haven't found a way to do that. Is this possible?

我想为特定标签创建一个子模块,但还没有找到方法来做到这一点。这可能吗?

回答by VonC

Once your submodule is created:

创建子模块后:

cd /path/to/yoursubmodule
git checkout yourTag
cd ..
git add yoursubmodule
git commit -m "use submoduile at tag xx"
git push

You records that way the fact you want a submodule at a certain tag.

您以这种方式记录您想要某个标签处的子模块的事实。