I wanted to use git filter-branch
to rewrite each commit or SHA1 message history with a different author and committer's date, e-mail, and name, but I've been warned against this usage and encouraged to use git-filter-repo
instead. I used this command, and it created backups, and I am prevented of rewriting the history. I used -f
, but it informed that the reference is unchanged.
I have read Changing author/committer(/tagger?) information . The question Git: Bulk change of commit dates answer isn't efficient. I also have seen https://stackoverflow.com/a/61368365/8041366 answer but it isn't efficient either.
But the documentation does not explain how to detect the commit or SHA1 message to change the author and committer's date, e-mail and name.
Of course, that this documentation warned me and recommended me to use git rebase
, but I hate git base
because it forces me to enter the text editor and to write edit
with author and committer's date, e-mail, and name. It consumes a lot of time. I prefer automatic Shell script.
Analyse my automatic Shell script (file choose-sha1-message
comes from https://stackoverflow.com/a/64044273/8041366):
#!/bin/sh
export TERM="linux"
export DIALOGRC="scripts/dialogrc"
source choose-sha1-message
sha="$(gsha)"
echo "Choose your complete GitHub or GitLab name"
read name
echo "Choose your GitHUb or GitLab e-mail:"
read email
echo "Choose your date (YYYY-MM-DD or YYYY/MM/DD):"
read ddate
echo "Choose your 24h hour (HH:mm:ss):"
read hour
echo "Choose your time zone:"
echo "For example, if you are from New York, then it is -0400, if from Paris, then +0100."
read zone
git filter-branch --env-filter \
'if [ $GIT_COMMIT = "$sha" ]
then
export GIT_AUTHOR_DATE="$ddate $hour $zone"
export GIT_AUTHOR_EMAIL="$email"
export GIT_AUTHOR_NAME="$name"
export GIT_COMMITTER_DATE="$ddate $hour $zone"
export GIT_COMMITTER_EMAIL="$email"
export GIT_COMMITTER_NAME="$name"
fi' $sha