a. Download replace-text.sh
b. Clone the gist repo in the same directory as replace-text.sh
-
using SSH url:
git clone git@gist.github.com:<reponame (hash)>
-
using HTTPS url:
git clone https://gist.github.com/<username>/<reponame (hash)>
git remote set-url --add origin git@gist.github.com:<reponame (hash)>
git remote set-url --delete origin https://gist.github.com/<username>/<reponame (hash)>
c. cd
into the gist repo directory
d. run replace-text.sh
on all commits
git filter-branch -f --tree-filter 'bash ../replace-text.sh <string> <my_string>' -- --all
e. restore dates
git filter-branch -f --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
f. Optional: remove dangling commits
git reflog expire --expire-unreachable=now --all
git gc --prune=now
g. Force push to remote repo
git push -f