The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven\'t yet been pushed upstream. The new messages inherit t
git commit --amend --date="now"
A better way to handle all of these suggestions in one command is
LC_ALL=C GIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"
This will set the last commit's commit and author date to "right now."
I wrote a script and Homebrew package for this. Super easy to install, you can find it on GitHub PotatoLabs/git-redate page.
Syntax:
git redate -c 3
You just have to run git redate
and you'll be able to edit all the dates in vim of the most recent 5 commits (there's also a -c
option for how many commits you want to go back, it just defaults to 5). Let me know if you have any questions, comments, or suggestions!
I created this npm package to change date of old commits.
https://github.com/bitriddler/git-change-date
Sample Usage:
npm install -g git-change-date
cd [your-directory]
git-change-date
You will be prompted to choose the commit you want to modify then to enter the new date.
If you want to change a commit by specific hash run this git-change-date --hash=[hash]
To change both the author date and the commit date:
GIT_COMMITTER_DATE="Wed Sep 23 9:40 2015 +0200" git commit --amend --date "Wed Sep 23 9:40 2015 +0200"
If you want to perform the accepted answer (https://stackoverflow.com/a/454750/72809) in standard Windows command line, you need the following command:
git filter-branch -f --env-filter "if [ $GIT_COMMIT = 578e6a450ff5318981367fe1f6f2390ce60ee045 ]; then export GIT_AUTHOR_DATE='2009-10-16T16:00+03:00'; export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; fi"
Notes:
^
), but I didn't succeed.Many thanks go to a blog post by Colin Svingen. Even though his code didn't work for me, it helped me find the correct solution.