Does github remember commit IDs?

My question how do I get github to show me all commit IDs for a file EVER

If you forced push (git push --force) your revised commit once in a while, that commit 8d8f7 has been replaced by a more recent commit with a different SHA.

That means 8d8f7 is now only reference in the reflog of the GitHub repo, which only GitHub support can give you access to.
Cloning the repo would not include 8d8f7 in the local history of that cloned repo.


GitHub “reflog”: push events from GitHub Events API

Actually the OP sindhus points out in the comments to “Recovering a commit from Github’s Reflog” by John Engelman:

The GitHub Events API allows to browse through the last events:

curl https://api.github.com/repos/<user>/<repo>/events

The “pushEvent” is the one to look for.

Then one can directly create a branch on GitHub in order to make that commit visible again (because not dangling anymore, but reference by an actual object like a branch):

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"ref":"refs/heads/D-commit", "sha":"384f275933d5b762cdb27175aeff1263a8a7b7f7"}' https://api.github.com/repos/<user>/<repo>/git/refs

# JSON request
{
  "ref": "refs/heads/D-commit",
  "sha": "384f275933d5b762cdb27175aeff1263a8a7b7f7"
}

You might need to use a token for the authentication.

Leave a Comment