How to change previous commit ID number with new Commit Id

By mistake I have Commited my code with wrong Commit Id number by follwing these steps:

git stash
git pull --rebase
git stash apply
git add .
git commit -m "commitId: msg"
git push
git fetch

But now I want to change my id. How can I do this ?


With git amend you can change commit message. Amend merges current change to the previous commit and will also change the commit hash and message.

$ git commit --amend --allow-empty -m "commitId: msg"   # Commit empty change
$ git push -f origin HEAD                               # Force (-f) push as history is changed 
链接地址: http://www.djcxy.com/p/49858.html

上一篇: 我想更改之前提交的Git提交消息

下一篇: 如何使用新的提交ID更改以前的提交ID号