kin3ow
Last Updated: February 25, 2016
·
864
· ydbondt

Change last commit

git

Oh no ! I just committed, providing a wrong message.
No problemo, you can just edit the log of the last commit:

git commit --amend -m "A better description"

Oh no! I forgot that file.

git add file
git commit --amend -m "blah"

Oh no! I forgot that file... but the message's good.

git add file
git commit --amend -C HEAD

Oh no! I forgot to git add ....

vim file
git commit --amend -aC HEAD

Thanks passcod for the update ! ;)

2 Responses
Add your response

549

Additional scenarios:

"Oh no! I forgot that file."

git add file
git commit --amend -m "blah"

"Oh no! I forgot that file... but the message's good."

git add file
git commit --amend -C HEAD

"Oh no! I forgot one last edit before committing everything."

$EDITOR file
git commit --amend -aC HEAD

I use that last one a lot.

over 1 year ago ·
550

Thanks ! Very usefull.
I updated the protip ;)

over 1 year ago ·