Problem with commit history in Bitbucket using Git

Viewed 372

I am facing issue to get back my previous commits, as soon as I used --f to push it shows just that commit where I used --f and earsed the previous ones. is there any way or any how to get back my commits history?

when I get back to link of the previous commit it shows this msg:

"This commit is unreachable from any branch or tag in this repository. It may be from a fork outside of this repository.

"

the code I used to push : git push -f origin master

1 Answers

You can use

git reset --hard <commithash you need> 

to restore your desired commit (you will need the hash obviously).

If you lost the desired commit hash you may be able to recover it using

git reflog

Make sure to backup your current work on a separate branch in case you make any mistake.

This might help you: https://www.jvt.me/posts/2021/10/23/undo-force-push/

Related