change last commit message

Premise

change last commit message
git-graph:

O   target-commit that you want to change its message [df9c192]
|
O   parent-commit [b7ec061]
|
O

Solution

git reset --soft b7ec061
git commit -m "new_commit_message"
git push -f

Explanation

  1. git reset --soft b7ec061 will keep your changes of files and reset to parent-commit (i.e. b7ec061)
  2. git commit -m "..." will locally create a new commit
  3. git push -f will push your new commit to the server and replace the old one (i.e. df9c192)

猜你喜欢

转载自www.cnblogs.com/expecto-patronum-/p/12935663.html