avp::ptr weblog

Everything that is in our mind.

Amend files to a git commit without changing the commit message

with 2 comments

Quiet often there is the need to add files to the recent commit. This can be done with 2 simple commands.

git add file
git commit --amend

In case you do not wand to change the commit message there is the new option --no-edit for git commit introduced in git 1.7.9. The git release notes describe how the --no-edit option can be used.

git commit --amend” learned “--no-edit” option to say that the
user is amending the tree being recorded, without updating the
commit log message.

git commit --amend --no-edit

Of course, I added an alias for the new option to my global git configuration.

ci = commit
cm = commit -m
ca = commit --amend
cn = commit --amend --no-edit

Written by tobi

February 5th, 2012 at 10:11 pm

Posted in Uncategorized

Tagged with , , ,

2 Responses to 'Amend files to a git commit without changing the commit message'

Subscribe to comments with RSS or TrackBack to 'Amend files to a git commit without changing the commit message'.

  1. Hello,
    It was very helpful, this had help from resetting my project just because I forgot to update .gitignore.

    Beladel ilyes Abdelrazak

    19 Mar 14 at 13:03

  2. I am using –amend not -am.

    weblogger

    10 Apr 16 at 18:48

Leave a Reply