Filter-Repo
git filter-branch is deprecated. Instead, use git filter-repo. You will need to install it.
Here is an excellent article about how to use git-filter-repo to modify the commit date. The git-filter-repo documentation explains the concept of --commit-callback pretty well.
A very simple example
Let's reset the timezone of all commit dates to zero.
# Save this as ../change_time.py
def handle(commit):
"Reset the timezone of all commits."
date_str = commit.author_date.decode('utf-8')
[seconds, timezone] = date_str.split()
new_date = f"{seconds} +0000"
commit.author_date = new_date.encode('utf-8')
handle(commit)
# You need to be in a freshly-cleaned repo. Or use --force.
git clone <...> your_repo
cd your_repo
# First just a dry run.
git filter-repo --dry-run --commit-callback "$(cat ../change_time.py)"
# And now do it for real
git filter-repo --commit-callback "$(cat ../change_time.py)"