As a Perl programmer and Open Source enthousiast, you probably sometimes contribute to Open Source projects. Maybe even (gasp!) during work hours. If your employer is jealous of your time, you probably do not want your commits to look like they were done during work hours (especially in tools like the GitHub Punch Card).
On the other hand, it doesn't make sense to not commit your changes, and lose the benefits of using Git, just so that the reality of when you worked on these tiny changes is not made public. (At that point, it would probably also make more sense to have an open discussion with your boss...)
The way Git handles history makes it really easy to change the date of commits on a local branch. When I first thought about it, my idea was to write some date manipulation code (move a bunch of commits from a time range to another with all kinds of fancy nooks and crannies) and manipulate the Git trees and commits myself.
Then I discovered git filter-branch, which is all about rewriting commits. And I realized that in the situation above, moving commits a few hours in the future (like ten minutes before actually using git push or git send-email) is largely sufficient.
The problem is that the code to move a bunch of commits one hour in the future looks like this:
git filter-branch --commit-filter '\ GIT_AUTHOR_DATE=`echo "$GIT_AUTHOR_DATE"|perl -pe'\''s/\d+/$&+3600/e'\''`;\ GIT_COMMITTER_DATE=`echo "$GIT_COMMITTER_DATE"|perl -pe'\''s/\d+/$&+3600/e'\''`;\ git commit-tree "$@"' --
Which is impossible to remember, and painful to write.
So, lazy as a Perl programmer should be, I just wrote git-move-dates, that writes and runs the above type of command-lines for me. Useful options include --committer and --author (to change only one of the two existing dates), and options ranging from --seconds to --weeks to define the exact timespan of your commits' time-travels.
As with my other Git gadgets, the source is available from http://github.com/book/git-gadgets.
And remember: there's nothing wrong with rewriting history, as long
as it's unpublished, local history. ;-)
Re:time zone?
BooK on 2009-12-16T13:14:39
Even simpler: just define the GIT_AUTHOR_DATE and GIT_COMMITTER_DATE environment variables before doing your commit.
Git understand several formats for those two variables.