Re: rewriting the entire git history... how?
On Tue, 9 Dec 2025, Tim Woodall wrote:
I want to rewrite git history from the very first commit (which is an empty
commit) but nothing I can find seems to let me do this other than with manual
intervention.
This is a one off and doesn't need to be efficient so long as I can leave it
to get on with it without intervention.
This is what I have: (private-email is a place holder)
===
#!/bin/bash
for commit in $( git rev-list --all --reverse master ); do
git cherry-pick --strategy-option=theirs $commit
echo "running sed"
sed -i 's/private-email@woodall.me.uk/builder@woodall.me.uk/g' $( git grep
-l 'private-email@woodall.me.uk' )
GIT_AUTHOR_DATE="$(git show -s --format=%ad HEAD)"
GIT_COMMITTER_DATE="$(git show -s --format=%ad HEAD)" git commit -a --amend
--reset-author --no-edit --allow-empty
done
===
replaced the cherry-pick with:
===
if ! git cherry-pick --allow-empty --strategy-option=theirs $commit; then
git rm $( git status | grep 'deleted by them:' | cut -d: -f2 )
git rm $( git status | grep 'added by us:' | cut -d: -f2 )
git add $( git status | grep 'deleted by us:' | cut -d: -f2 )
git cherry-pick --continue --no-edit --allow-empty
fi
===
and so far it's making progress...
Reply to: