I found myself amending my commits quite often. I don't stash
so much because I tend to forget I did so, especially when I want to save what I did before I leave or before a weekend, so I do a "draft" commit. Only thing is, when I amend the commit, it is still set to the original author date. Is there a (simple) way to update it when amending?
Just do git commit --amend --reset-author --no-edit . For older commits, you can do an interactive rebase and choose edit for the commit whose date you want to modify.
You can modify the most recent commit in the same branch by running git commit --amend. This command is convenient for adding new or updated files to the previous commit. It is also a simple way to edit or add comments to the previous commit. Use git commit --amend to modify the most recent commit.
commit message Show activity on this post. Amending a Git commit changes the commit date (which is different from the date you initially see when running git log -- run git log --format=fuller to see the commit date). The commit date is taken into account when creating the commit hash.
You can change the author date with the --date
parameter to git commit
. So, if you want to amend the last commit, and update its author date to the current date and time, you can do:
git commit --amend --date="$(date -R)"
(The -R
parameter to date
tells it to output the date in RFC 2822 format. This is one of the date formats understood by git commit
.)
As of Git v2.1.4 (tested on Debian 8 (Jessie))
git commit --amend --date=now
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With