我在我的项目中引用了一个 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 中设置它的方法是通过 cd
ing 进入子模块,检查你想要的 SHA1,然后 cd
ing 回到父 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/