If you've removed a commit with git reset --hard
, it's still possible to recover the commit using git reflog
to look up the commit hash.
Once we find the right commit hash, we can reset our branch back to that commit hash with git reset --hard [HASH]
NOTE! git will actually garbage collect abandoned commits (every 30 days or so - so not very often) - so you can't recover from a reset --hard
forever; which is why it's recommended to avoid --hard
if you ever want to references those changes.