Git Rebase Autosquash
Problem
You have the following local commits:
edf23a5 (HEAD -> main) Make a legal page
88c90a5 Make a contact page
70d0caa Make an about page
eecd26c Make a homepage
The problem is you find a typo on the contact page, and you do not want to make a new commit.
Solution
You can solve it with git rebase.
git commit --fixup COMMIT_HASH
git rebase -i --autosquash COMMIT_HASH
Steps:
- Copy the commit hash that you want to fix.
- Execute
git commit --fixup 88c90a5. - Copy the commit hash before the commit that you want to fix.
- Execute
git rebase -i --autosquash 70d0caa. - Close the editor.
Once you are done, you get a new commit hash for the targeted commit and the commit above it.
2a37136 (HEAD -> main) Make a legal page
608b1eb Make a contact page
70d0caa Make an about page
eecd26c Make a homepage
Share your thoughts Topic(s).
Thank you for reading this Git Rebase Autosquash. 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-rebase-autosquash/
For you
Read This before You Go Crazy
Warning: Reader discretion is advised. This article contains disturbing content.
By Vanza Setia
Clean Plate
Do you love wasting your food?
By Vanza Setia