Initially, my intention was to remove some long ago commit from one of my GitHub repositories using the following command from one of the answers to this question: Undoing a ‘git push’
git push -f origin commit:branch
Apparently, I was distracted and seem to have forgotten that this way I’ll “undo” all the commits up to the one referenced. Also, usually working with GitHub Desktop to commit/push/pull in my private repositories only, I probably have not understood how Git works on a command line (with all this “complex” stuff possible). I realized I might have messed up big time when GitHub Desktop suggested to push (?) 63 commits to the remote repository. Yeah, I pretty much panicked and deleted my local copy – only to pull the repository again and realize that the changes affected the remote repository.
I found another answer to the question Is there anyway to undo git push -f? sounding promising at first but since I might have messed up a second time by panicking, I obviously cannot scroll my terminal to determine the relevant commit to be restored and git reflog
also does not seem to be of help since this repository is freshly cloned, as far as I understand.
>git reflog
7a7a940 (HEAD -> main, origin/main, origin/HEAD) HEAD@{0}: reset: moving to ORIG_HEAD
7a7a940 (HEAD -> main, origin/main, origin/HEAD) HEAD@{1}: rebase (finish): returning to refs/heads/main
7a7a940 (HEAD -> main, origin/main, origin/HEAD) HEAD@{2}: rebase (start): checkout HEAD~7
7a7a940 (HEAD -> main, origin/main, origin/HEAD) HEAD@{3}: rebase (finish): returning to refs/heads/main
7a7a940 (HEAD -> main, origin/main, origin/HEAD) HEAD@{4}: rebase (start): checkout main
7a7a940 (HEAD -> main, origin/main, origin/HEAD) HEAD@{5}: clone: from https://github.com/dimfalk/rainfallr.git
However, since it’s feeling like I’m pretty much making it worse every time I reach for a blade of grass without any real idea what I’m doing, I decided to get some help.
Is there any chance I can restore these “lost” 63 commits from over the past 2 years or are they inevitably lost now?