In this question someone answers with a git filter-branch command in this post. But, I would like to know what the equivalent is in git filter-repo as git filter-branch is the old and slow command and git filter-repo is supposed to be the replacement. Does anyone know what the git filter-repo equivalent is of this?
git filter-branch --env-filter \
'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ]
then
export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
fi'
The general syntax for a commit callback using
git-filter-repois:Note that with
filter-repoyou need to use Unix timestamps, which can be converted here.When using
filter-repo, if you don't have a fresh clone (which is highly recommended), you'll need to use the--forceoption.Here's the above example in action which changes both authors, both emails, both dates, and the commit message of a specific commit, with the before and after:
Example:
Another way to do it without using a callback
Here's a simple general algorithm for making changes to commits that don't affect the state of the file system. Examples of non-state changes are commit authors, dates, or the commit message.
git replace <old-commit-id> <new-commit-id>git filter-repo --replace-refs update-or-add