Search code examples
gitgithub

git lost master branch


Hi i have a private repository here. https://github.com/Nuvelle/The-Last-Knights. i dont know what happened i was working last night and suddenly my master is showing only initial commit , committed 12 hours ago. there is no history and nothing.i ave been trying since morning to figure it out. any help is appreciated

screenshot


Solution

  • A possible explanation is a git push --force of a reset master branch.

    While the local reflog might show only one commit, you might find trace of the old remote master branch state on GitHub side with the with the "poor man's reflog", aka the push events (GitHub Events API).
    See "Does github remember commit IDs?": look for any recent push events on the master branch: you can then fetch that commit (and its associated history) back to your local repo.
    If not, the GitHub support will have a look in order to restore your previous content.

    The OP Azwar Habib added in the comments:

    git fsck --full --no-reflogs gave me list of all lost commits.
    And then from there git reset -- hard [commit] restored my branch to that commit.

    A forced push is then needed to restore the same history on the remote side.