Lost some files in a Git versioned project and could only recover them... in a fork on Github
Lately I realized that I had lost some files in one of my projects hosted on Github, jquery.transition.js. I searched in the commit history to try to find when and how that happened but couldn't find any related commits.
Then I looked at its network graph on Github and found all of the commits and files in someone else's fork: https://github.com/ammonkc/jquery.transition.js/tree/gh-pages
I'm wondering how this is possible. Could it be that I inadvertently deleted the gh-pages branch and overwrote it? Shou开发者_运维技巧ldn't that appear in the commit history?
What usually can happen is:
- a branch deleted or a forced push where those commit are no longer referenced
- a fork done prior to that event which still referenced said commits
Such a push (with a rewritten history without those commits) can only happen if it is "forced" (push --force
), but wouldn't leave a trace in the visible history (since the commits have been rewritten).
Even in the worst case scenario, the lost commits are still referenced in the reflog, which you can:
- ask for at the GitHub support (they can create a branch referencing said lost commits).
- or (as repo owner) query the GitHub events API:
See "Does GitHub remember commit IDs?"
精彩评论