1

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 ?

NARGIS PARWEEN
  • 1,489
  • 3
  • 16
  • 26
  • 2
    Possible duplicate of [Changing git commit message after push (given that no one pulled from remote)](http://stackoverflow.com/questions/8981194/changing-git-commit-message-after-push-given-that-no-one-pulled-from-remote) – LF00 Dec 01 '16 at 10:49

1 Answers1

0

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 
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73