I'm referencing a git submodule in my project, and now need to reference a specific SHA in the target git repo.
# .gitmodules [submodule "vendor/plugins/ssl_requirement"] path = vendor/plugins/ssl_requirement url = git://github.com/retr0h/ssl_requirement.git
The SHA I want is bc96ad96407a72a60e0542cf3b0cecc6ff9e278e
.
Use the git submodule update command to set the submodules to the commit specified by the main repository. This means that if you pull in new changes into the submodules, you need to create a new commit in your main repository in order to track the updates of the nested submodules.
Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.
If you already cloned the project and forgot --recurse-submodules , you can combine the git submodule init and git submodule update steps by running git submodule update --init . To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive .
Submodules, by definition, always reference particular SHA1 in the subproject. That SHA1 isn't expressed in the .gitmodules
file, but is instead expressed as the entry in the tree object that contains the submodule. The way you set this in git is by cd
ing into the submodule, checking out the SHA1 you want, then cd
ing back to the parent repo and committing your change, which will show up just like a changed file.
So in your case what you can do is
cd vendor/plugins/ssl_requirement git checkout bc96ad96407a72a60e0542cf3b0cecc6ff9e278e cd .. git add ssl_requirement # commit whenever you're ready
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With