I downloaded a ZIP file of a project commit. After making some changes, I ran the commands:
git init
git branch -m main
git remote add origin <url>
git add .
git commit -m "message"
git push -f origin main
After running these commands, all commits that were made before were deleted and this was the only commit in the branch. I tried running
git fsck --unreachable
git log
git reflog
but I couldn't find the lost commits
For anyone having similar problems, if you download a ZIP file of a repository, it doesn't include the git history. Because of that, when you push your changes, there is no history of any commits before that. If you or a colleague have another version with the history, you can simply push that. If not, the best approach is to contact the Github support and ask them for help as they keep all the commits so they can probably restore it for you but I haven't personally tested this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.