Restoring an overwritten repository #175704
-
Select Topic AreaQuestion BodyI initially had five sub-folders in my repository and i recently did a force commit to my repository. This ultimately overwrote every commits and files that I had in the repository leaving me with only one sub-folder. I also wanted to do git reflog but my commit history is empty hence I couldn't find the previous commit SHA. I want this repository restored to the last push, which was approximately last week.: repository https://github.com/cruzrafaelx/fullstack-open Can anyone help me? I badly need to have this restored since I am aiming to submit this to the University of Helsinki... I'm very desperate for support at the moment. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
|
You’re safe, here is the commit u are missing: After some years, I recommend restoring history directly: from any clone with push accessgit push --force-with-lease origin a755ab9ab3e83125bb9b4a0a575239a78cc0c4d4:main |
Beta Was this translation helpful? Give feedback.
-
|
If you force-pushed and lost all the commits locally and your reflog is empty, then sadly you can’t recover it just from your machine. But since you said the code was pushed to GitHub last week, there’s still hope. GitHub keeps snapshots of your repository history, even after a force push. 👉 What you can do:🫡🫡🫡 Go to your repository on GitHub. Click on the "Commits" tab. If GitHub still has the old commits, you’ll see them listed there. You can click on the last good commit and download the code (via the “<> Code” button → “Download ZIP”). If the commit list is empty, then you’ll need to contact GitHub Support and request them to restore the repository to the last known push. Provide them with your repo link and explain you lost history after a force push — they can often help. |
Beta Was this translation helpful? Give feedback.
it was pure real life experience:
go to the url:
https://github.com/cruzrafaelx/fullstack-open/tree/main <- main is the branch
then add @{1} or @{2} or @{3} = https://github.com/cruzrafaelx/fullstack-open/tree/main@{1}
or if u have the date main@{2025-09-27} = https://github.com/cruzrafaelx/fullstack-open/tree/main@{2025-09-27}