Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get SHA1 hash from a git repository without cloning?

Tags:

git

hash

If U is a git URL (e.g., an ssh URL), how can I find the SHA1 hash of a branch or tag of U without a local clone of U?

like image 329
rlandster Avatar asked Jan 18 '13 23:01

rlandster


People also ask

What is the SHA-1 hash used for in git?

Background. At its core, the Git version control system is a content addressable filesystem. It uses the SHA-1 hash function to name content.


2 Answers

You can get heads (branches) and tags with git ls-remote U.

like image 120
ellotheth Avatar answered Oct 15 '22 09:10

ellotheth


You can use this: git ls-remote U branch | cut -c1-7 where, 'branch' specifies the commit hash from that particular branch

like image 27
Saurabh Shah Avatar answered Oct 15 '22 09:10

Saurabh Shah