Git 子模块 : specify a specific SHA?

标签 git git-submodules

我在我的项目中引用了一个 git 子模块,现在需要在目标 git 存储库中引用一个特定的 SHA。

# .gitmodules
[submodule "vendor/plugins/ssl_requirement"]
  path = vendor/plugins/ssl_requirement
  url = git://github.com/retr0h/ssl_requirement.git

我想要的 SHA 是 bc96ad96407a72a60e0542cf3b0cecc6ff9e278e

最佳答案

根据定义,子模块始终引用子项目中的特定 SHA1。 SHA1 不在 .gitmodules 文件中表示,而是表示为包含子模块的树对象中的条目。你在 git 中设置它的方法是通过 cding 进入子模块,检查你想要的 SHA1,然后 cding 回到父 repo 并提交你的更改,这将像更改后的文件一样显示。

所以在你的情况下你可以做的是

cd vendor/plugins/ssl_requirement
git checkout bc96ad96407a72a60e0542cf3b0cecc6ff9e278e
cd ..
git add ssl_requirement
# commit whenever you're ready

关于Git 子模块 : specify a specific SHA?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8813249/

相关文章:

git merge 分支覆盖目标

git - 接受 git 中的所有 merge 冲突

Git 子模块 : Is it possible to notify other developers of a change?

git checkout 版本,包括子模块

git - 子模块是用于插件还是用于依赖项?

git - 检测两个 git diff 之间的 merge 冲突,而无需访问原始存储库

java - fatal :unable to update url base from redirection. ..无法解决

linux - Git - Windows 和 linux 行尾

git - 如何将目录的子目录添加为 git 子模块?

git - 使用不同子模块设置的 checkout 提交无法正常工作