git clone release code example
Example 1: git clone release
curl -s https://github.com/USER/REPO/releases |
grep -m1 -Eo "archive/refs/tags/[^/]+\.tar\.gz" |
xargs printf "https://github.com/USER/REPO/%s"
ghRepoCloneLatestRelease ()
{
[[ ${1} =~ / ]] &&
wget -qO- https://github.com/${1}/$(curl -s https://github.com/${1}/releases |
grep -m1 -Eo "archive/refs/tags/[^/]+\.tar\.gz") |
tar --strip-components=1 -xzv >/dev/null
}
Example 2: git clone latest release
You can do this with the --branch flag, which will also accept a tag.
$ git clone [email protected]:mygitname/theproject.git --branch 1.0.2
In most cases, you will just want to checkout the tag as described in Exprator's answer.