I recently pushed a commit to my git remote repository, and now I'm going to commit another change.
Is there a way I can merge these commits into a single commit?
You can do this using interactive rebasing.
Run the following:
git rebase -i HEAD~2
You'll see something like this, in the editor that opens:
pick 3e7ee36 Older commit message
pick fa20af3 Newer commit message
# Rebase 8db7e8b..fa20af3 onto 8db7e8b
# ...
fixup or squash the newer commit, i.e., replace the pick in the newer commit to fixup and save and quit the file. This will merge the 2 commits keeping the older message:
pick 3e7ee36 Older commit message
fixup fa20af3 Newer commit message
# Rebase 8db7e8b..fa20af3 onto 8db7e8b
# ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With