github - get git hash for commit with specific tag without cloning or pulling

git, github

Solution

so I started out with what @hvd said:

git ls-remote REPOLINK TAG

but that gave me only the tag hash, and I want the commit hash.

so I went back to:

git ls-remote REPOLINK 

and decided to grep for the tag:

git ls-remote REPOLINK | grep TAG

so now I have 2 rows, the first with the tag hash, and the 2nd with commit hash. so first we need to take just the second line:

git ls-remote REPOLINK | grep TAG | sed -n 2p

and we now have:

HASH TAG

now lets cut off everything but the first column to get the hash:

git ls-remote REPOLINK | grep TAG | sed -n 2p | cut -f1

Problem

I wish to get the git hash for a specific tag. For now what I do on the job is: ``` git clone GITHUB_URL git checkout TAG cd REPO_NAME export GIT_HASH=$(git log --pretty=format:%h -1) ``` Is there any chance I can get this without cloning or pulling or checking out?

Original source