For a normal git repo you can do:
git clone --branch 4.1.1 https://github.com/WordPress/WordPress.git . --depth 1
Which will give a WP repo at tag 4.1.1
For a submodule I did get the below but I can't figure out how to do it for just one tag.
git submodule add --depth 1 https://github.com/WordPress/WordPress.git wp
How do I checkout a submodule to 1 tag at 1 depth?
I don't mind doing a few more commands afterwards but if possible in one command even better.
TLDR: I want a submodule at a tag. Which .git(/module) folder is as small as possible.
Considering a submodule might not comes with its tags, you might be tempted to do first (as suggested in "Can git submodule update be made to fetch tags in submodules?"):
git submodule foreach --recursive 'git fetch --tags'
But as I explained in "Does “git fetch --tags
” include “git fetch
”?", that would not fetch just the tags, but also all the associated commits (since git 1.9.0, February 2014)
Instead, you can go in the submodule, and fetch that tag content with a depth of 1:
git fetch --depth=1 origin refs/tags/<tag>:refs/tags/<tag>
git checkout <tag>
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