For a few days I was re-writing install.sh file for Scrollback project and since I was the only one working on this and doing it locally, I kept commit ammending the same commit, pushing once in a while to my fork's master. (please ignore best practises here, I was working alone).
In between I remember emailing someone showing my half done work, the URL https://github.com/sindhus/scrollback/blob/8d8f7f414383499c2ab6fec586b4c9665a41c7aa/install.sh
Now by some confusion I lost out on my work locally (think rm -rf), I remember pushing prior to this. So github at some point did see my rebased commit ID of install.sh.
As you can see the above URL lets me access this blob by a commit ID. However I can't access it locally because that same repo was force pushed.
My question how do I get github to show me all commit IDs for a file EVER? All IDs it possibly knows of for that file regardless of path. If I have to use their API I don't mind but I'd like some ideas to dig deep into this.
Thanks!
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.
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.
i didn't really get the question so there is some solution:
To see all commit of a specific file:
git log --follow filename
.
To checkout to old version, find answer here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With