Does github remember commit IDs?

For a few days I was re-writing 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

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

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.


  • How do I use GitHub through harsh proxies?
  • How to deploy in gh-pages with index.html as a symlink to a subdirectory
  • change github account mac command line
  • Stop Modifications in new feature Branch from Merging into Master using GitGui
  • Multiple unpublished commits - Unable to publish any. What's wrong?
  • Git: Cloning through symlink requires password?
  • Get name of tracking branch + remote name
  • Do I need Git to use Github in JetBrains IntelliJ IDEA?
  • 4 Solutions collect form web for “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:


    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"}'<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

    Clone your repo locally then try this on your file:

    git log --follow

    It should show you IDs that you can use on github.

    I’m not sure if there’s a single way you can get all versions of a file across amended commits. However, reflog will contain information on the earlier ones and you can extract them manually. An example follows.

    This is my first commit

    echo "a" > a.txt && git add a.txt && git commit -m "Version 0"

    After that, a few more amends.

    % echo "aa" > a.txt && git add a.txt && git commit --amend -m "Version 1"
    % echo "aaa" > a.txt && git add a.txt && git commit --amend -m "Version 2"
    % echo "aaaa" > a.txt && git add a.txt && git commit --amend -m "Version 3"
    % echo "aaaaa" > a.txt && git add a.txt && git commit --amend -m "Version 4"

    While my log just one entry

    % git log –oneline
    a8d6c39 Version 4

    My reflog has everything

    % git reflog master
    a8d6c39 master@{0}: commit (amend): Version 4
    cf87b8f master@{1}: commit (amend): Version 3
    c45a91e master@{2}: commit (amend): Version 2
    63c7f5a master@{3}: commit (amend): Version 1
    f2b3336 master@{4}: commit (initial): Version 0

    So, if you want to see what your file looked like at Version 4, Version3 etc., you can do this

    % git show a8d6c39:a.txt
    % git show cf87b8f:a.txt
    % git show c45a91e:a.txt
    % git show 63c7f5a:a.txt
    % git show f2b3336:a.txt

    In general though, the “process” of continuously amending is bad even if you’re the only developer. It’s a one off thing you should do to fix mistakes the last commit.

    Git Baby is a git and github fan, let's start git clone.