How to modify git message

  1. modify the last commit comment: git commit --amend --message="message" --author="my_name <name@email.com>"

  2. modify historical commit comment:

    1. view your commit history: git log

    2. rebase: git rebase -i <commmit id> or git rebase -i HEAD~n

      1. note: you have to rebase to the commit before the one you want to modify.
    3. change the flag:

      • pick: use commit (do nothing)
      • reword: use commit, but edit the commit message
      • edit: use commit, but stop for amending (u can modify files)
      • squash: use commit, but meld into previous commit
      • fixup: like "squash", but discard this commit's log message
      • exec: run command (the rest of the line) using shell
      • drop: remove commit

      If you just want to edit the commit message, choose reword.

    4. modify the message

    5. push git push <origin> <branch> -f. You have to use the flag -f to push the commit by force.