In case you ever need to rename a variable across multiple (e.g. 10) git commits:

git rebase -i HEAD~10 --exec 'git diff --name-only --diff-filter=AMC HEAD~ | xargs sed -i "s/BEFORE/AFTER/g"; git commit -a --amend --no-edit'

To edit commit messages:
git filter-branch -f --msg-filter 'sed -e "s/BEFORE/AFTER/g"' HEAD~10..HEAD

Based on:

I needed this for (and dozens of commits on top later):

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!