Reputation: 4003
I want to write a simple script that would go over a git repo and change the timestamp of each commit accordingly. Yet, I have no idea where to begin from. Any advice for a first step?
Upvotes: 0
Views: 185
Reputation: 72745
Use git filter-branch
. It has a number of filters you can apply which can alter commits. Be warned that it's destructive and will rewrite the history of your project.
Upvotes: 0
Reputation: 213308
The git filter-branch
(docs) command is designed to do tasks exactly like this. The trick is figuring out what you want to change the timestamps to.
You can pass a filter to git filter-branch
using --commit-filter
, then modify the GIT_AUTHOR_DATE
and GIT_COMMITTER_DATE
environment variables. Here is an example, which sets the commit date of all commits to January 1, 1970:
git filter-branch --commit-filter 'GIT_COMMITTER_DATE=1970-01-01T12:34:56'
Upvotes: 1