I know that if I have a Git repository checked out, I can use the git
CLI to get the current commit hash. But is there a way to do this just over HTTP, without cloning the repository?
For example, let's say that I want to get the current hash of https://github.com/jashkenas/coffeescript. Manually, I can go to the page, press Y
on my keyboard, and see that the hash is (at the time of this writing) 1f197fcc1bf1a15bc45a6b23fb3f706ffcb77025
. Which means that if at some later point I wanted to download the CoffeeScript source as it is at this moment, I could download https://github.com/jashkenas/coffeescript/archive/1f197fcc1bf1a15bc45a6b23fb3f706ffcb77025.zip, and it would give me the source.
Is there a way to do this just using HTTP (e.g. curl)? Can I hit some endpoint which will tell me what the current hash is of the default branch? Generalizing a bit, are there endpoints which will tell me the hash of
- The HEAD of the default branch,
- the HEAD of a given branch, or
- a particular tag?