Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the hash of a tag

Tags:

git

I am working on a "big" project, and it has several tags.

Regularly, tarballs are generated and saved with the last hash in their name (not the best practice, but it's how it rolls).

The following need has risen: We would like to download from our server the tarball identified for tags/v1.0.0.

The question is now: how can I get the hash of that tag without cloning the whole project?

EDIT (OP): The question was unclear. I do not want to download the project, as it is big, and the only piece of information I want is the hash of the tag.

like image 384
fzd Avatar asked Oct 18 '22 00:10

fzd


1 Answers

When you are trying to get some information you can use ls-remote.

In your scenario you would do the command:

git ls-remote <remote> refs/tags/v1.0.0

This will output something along the lines of:

e8b29c3c46a59dc59e2a3b22c253860c23a9ea39 refs/tags/v1.0.0

which you should be able to mangle into something useful :)

<remote> is the remote that you are querying. A complete example with another reference to get the sha of the master branch would be:

git ls-remote ssh://[email protected]/praqma-training/gitkatas refs/heads/master

with output:

634c33168ee434a10f74e3254c3f5f548f263250 refs/heads/master.

Good luck!

like image 64
RandomSort Avatar answered Oct 21 '22 05:10

RandomSort