Git-logo A lot of time, I had to modify the text of my commit since I’m using a versionning system. Modifying the last commit comment is something common:

git commit --amend

However, modifying the date is not so common. You may want to do it for several reasons (stats or similar), here is how to:

GIT_COMMITTER_DATE="`date`" git commit --amend --date "`date`"

This will change the last commit with the current date.

The last thing I wanted to do is modifying the author. Because I’ve a personal and professional GitHub account, I made mistake several times using the wrong account. Here is a solution to rename author commits:

git filter-branch --env-filter '
oldname="old username"
oldemail="old email address"
newname="new username"
newemail="old username address"
[ "$GIT_AUTHOR_EMAIL"="$oldemail" ] && GIT_AUTHOR_EMAIL="$newemail"
[ "$GIT_COMMITTER_EMAIL"="$oldemail" ] && GIT_COMMITTER_EMAIL="$newemail"
[ "$GIT_AUTHOR_NAME"="$oldname" ] && GIT_AUTHOR_NAME="$newname"
[ "$GIT_COMMITTER_NAME"="$oldname" ] && GIT_COMMITTER_NAME="$newname"

If you want to know more about some git tips, you can look at my wiki page.

Hope this will help