I want to change Git's commit message later

programming

I check every time I commit without hitting a message by mistake, so I output it to remember it soon.

Change the previous commit message

$ git commit -m "fix users.vuw"

"Ah! I came with typo!!! 」

At that time, it can be corrected like this.

$ git commit --amend --m "fix users.vue"

Change the message of a previous commit

There may be such a thing…

$ git add .
$ git commit -m "fix users.vuw"
...
$ git add .
$ git commit -m "fix login"
...
$ git add
$ git commit -m "fix logout"

"Ah! I'm typo in the previous three commit messages!!! 」

When I say, I will fix it like this.

 $ git rebase -i HEAD~3

When you run this command, the vi editor will start, so if you modify it there, you will see k.

By the way, HEAD to 3refers to three things that go back from HEAD.

タイトルとURLをコピーしました