The following steps can be taken to recover a lost Github commit. e.g. An accidental push force removed the commits.
-
Get a personal token with repo access from: https://github.com/settings/tokens Make sure the token has privileges to read/write the repository.
-
Use the token to access the events history of the repo: The relevant key value in the JSON response is the
sha
:
$ curl -u {USERNAME}:{ACCESS_TOKEN} 'https://api.github.com/repos/{OWNER}/{REPOSITORY}/events?page=1'