- Setup git-filter-repo from https://github.com/newren/git-filter-repo
- Setup replace file with strings to replace and place it to your project root package: replaces.txt
password_1==>0001
password_2==>0002
password_3==>0003- Replce your strings locally by do this command in your project path: git filter-repo --replace-text replaces.txt --force
- After execution the script the IDE sometimes deletes the Git Remotes, so set it again (Git -> Manage Remotes -> Add)
- Create a script clear.sh and give it execution rights (in terminal): chmod +x clear.sh
#!/bin/bash
# 1. Get all branches
branches=$(git branch)
# 2. Get all tags
tags=$(git tag)
# 3. Force push all branches
for branch in $branches; do
# Remove "origin/" at the start of branch name
branch_name=$(echo $branch | sed 's/^origin\///')
# Push branch
git push origin refs/heads/$branch_name --force
done
# 4. Force push all tags
for tag in $tags; do
# Push tag
git push origin tag $tag --force
doneCAREFUL! IN THIS STEP YOU WILL FORCE PUSH ALL GIT HISTORY TO REMOTE REPOSITORY. BE SURE YOU KNOW WHAT IT IS AND HAVE ALERTED YOUR COLLEAGUES WHO ALSO WORK IN THIS REPOSITORY!
- Execute script in your project path: sh clear.sh
- Tell your colleagues to clone "new" project
- Done!
You can check that all strings was removed from git history by command: git grep "string" $(git rev-list --all)