How can GitHub change the commit message just pushed


One sentence summary

First git rebase the pointer before submitting, then git commit — modify commit message, and finally push back

Git rebase – I head ~ 5 ා, showing the last 5 times of submission, can be changed to other numbers


previously on

Today it was all night again. I misspelled a word when I committed. I remembered that I wrote a wrong word “and” in my homework late in primary school

At this time, I need to change the commit, but I have already pushed… (all because I am too sleepy)

BTW can be used without push

# git commit –amend

This line of code will open your latest commit, and you can edit your comments.

But I have submitted it. What should I do?

a key

Go back to before you submit

Git rebase – I head ~ 1 ා shows the last submission, which can be changed to another number to display the last n commits

Then a VIM will come out with the commit message submitted. Press I to change the pick before the commit to edit mode, and then press ESC to exit the insert mode,: W save: Q exit. Don’t forget the colon. More VIM instructions from Kangkang~

At this time, you can modify the commit

Git commit — modify commit

Then a VIM will appear. You can see that the first line is the commit message that has just been submitted in question. Or press I to enter the insert mode, change the commit message to the desired one, and then: WQ save + exit.

Use it after modification

Git rebase — continue? Update this rebase

It’s done here. Next, push again to cover the last commit~


You may need merge, but this time just change the commit message. In fact, nothing has changed. Just pull and then push~