Git Reflog
Problem
You have done a git rebase. Then, you do not like that decision. You want to undo that.
Solution
You solve the problem with git reflog.
You have the following reflog:
2a37136 (HEAD -> main) HEAD@{0}: rebase (finish): returning to refs/heads/main
2a37136 (HEAD -> main) HEAD@{1}: rebase (pick): Make a legal page
608b1eb HEAD@{2}: rebase (fixup): Make a contact page
88c90a5 HEAD@{3}: rebase (start): checkout 70d0caa
90ca0c5 HEAD@{4}: commit: fixup! Make a contact page
edf23a5 HEAD@{5}: reset: moving to HEAD~1
d785b41 HEAD@{6}: rebase (finish): returning to refs/heads/main
d785b41 HEAD@{7}: rebase (start): checkout eecd26c
d785b41 HEAD@{8}: commit: fixup! Make a homepage
edf23a5 HEAD@{9}: commit: Make a legal page
88c90a5 HEAD@{10}: commit: Make a contact page
70d0caa HEAD@{11}: commit: Make an about page
eecd26c HEAD@{12}: commit (initial): Make a homepage
You want to go back to the state where you have not made a fixup! commit for the contact page. You also do not want to lose any local changes.
Steps:
- Execute
git reflogto get the above output. - Copy the state hash that you want to go back to.
- Execute
git reset --mixed edf23a5.
Topic(s).
Thank you for reading this Git Reflog. You can subscribe to all my articles with the Articles RSS. If you have a positive or negative comment, please send me an email or contact me through one of my social media accounts.
Share with your network
Copy this link and send it to great people only.
https://vanzasetia.xyz/blog/git-reflog/
For you
Proudly Inaccessible
I announce that this website is not accessible to everyone. I expect that I will never try to make it accessible to all people.
By Vanza Setia
Clean Plate
Do you love wasting your food?
By Vanza Setia