avp::ptr weblog

Everything that is in our mind.

Archive for the ‘amend’ tag

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 , , ,

Reset the author of a git commit

without comments

Once in a while one forgets to configure the user name and email address for git when initializing or cloning a new git repository. So do I. But git would not be git if it does not have an answer to that problem. Here is what git prints out when you commit without previously configuring the user credentials.

$ git cm 'Initial import.';
[master (root-commit) 0396c37] Initial import.
Committer: User User@Machine.(none);
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name ''Your Name''
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file

Well done git!

Written by tobi

February 5th, 2012 at 9:54 pm

Posted in Uncategorized

Tagged with , , , ,