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
-
um because your repository is private I can't check it out, but are you sure you're checking the correct branch and that you've pushed your commits to GitHub? – umop apisdn May 24 '18 at 17:09
-
yes i was pushing to master. i have been using master for 2 years. but now master only shows initail commit and that too created 12 hours ago. and no history and nothing else – Azwar Habib May 24 '18 at 17:17
-
1How a question like this earns an upvote I'll never know... We have _no way_ of knowing what happened based on what you've told us. What was there before? What commands, exactly, did you run? Did you force push? Does your local `master` look like this? If not, how does it look? Please read [ask]. – ChrisGPT was on strike May 24 '18 at 17:17
-
I'm assuming that you currently have no clone of the repository on a local machine ? This sounds bizarre a little ... – sylvain.joyeux May 24 '18 at 17:20
-
i use gitkraken gui. i did a force pull.i was trying to pull my repo on my second laptop. and i dont know what happened. if i knew what comamnds were run thn i would know myself what happend . no? and secondly i tried reflog it only shows one commit. and mater previously ha dlike 300 or so files. and i do have a clone on my other pc. but i am trying to figure out what happened and why there is no history. – Azwar Habib May 24 '18 at 17:26
-
@AzwarHabib Did you find back your lost commits? – VonC May 24 '18 at 18:07
-
git fsck --full --no-reflogs gave me list of all lost commits. and then from there git reset -- hard [comit] restored my branch to that commit. thanks for all the help everyone. – Azwar Habib May 24 '18 at 18:34
1 Answers
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 theregit reset -- hard [commit]
restored my branch to that commit.
A forced push is then needed to restore the same history on the remote side.

- 1,262,500
- 529
- 4,410
- 5,250