Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git checkout to recent commit

Tags:

git

I have a total of 24 commits, and I had checkout to commit 15. How can I go back to my last commit?

Note: I have run a lot of commits. For instances,

git revert, git checkout, git reset.

I don't know my last commit name, id, or even the files. All I know that I have committed, but I am not there.

but I could not go back to my latest commits.

Thank you

like image 903
Nimatullah Razmjo Avatar asked May 02 '26 04:05

Nimatullah Razmjo


1 Answers

Finally, with help of friends in here I come up with solution. the resean I post this. It may help other as well.

First, I used to git reflog to show all my last commit.

Second, I used git checkout commit_id

Third, git log --graph --decorate --pretty=oneline --abbrev-commit master github/master temp.

Then, git branch -f master temp.

And, git branch -d temp.

Finally, git push --force github master

like image 174
Nimatullah Razmjo Avatar answered May 04 '26 22:05

Nimatullah Razmjo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!