I've seen a few topics relating to this topic but none exactly mirrored my situation. In most of those people pushed the wrong branch overwriting another or just needed to be able to restore the remote repo's commits from their local repo.
In my case, I have an old repo that I must have deleted locally. I still had the remote repo on GitHub and it maintained all my commits.
Somewhere along the way I must have cloned the repo onto my system but never reinitialized the local repo with git (ie didn't have a .git file nor did my terminal show git status). I believe the original local repo was on another machine before I formatted the hard drive. I continued to work on the program locally.
I ran:
git init
git add remote https://github.com/...
git push origin master
It gave me a message saying my local repo did not have some of the changes that were made on the remote repo. (Keep in mind that the local repo does not contain my commit history, only the remote GitHub repo does (did)).
At the time I didn't think I needed the additions from GitHub and that the local repo was the most up-to-date, so I ran:
git push -f origin master
It went through just fine and I thought all was well. Until I logged into my GitHub. To my horror, I read the fateful words "1 commit".
So is there a way to restore the historical commits from that repo? I can't find them anywhere.