snippets:git:remove-sensitive-data
Git: remove sensitive data
Link: https://help.github.com/articles/remove-sensitive-data
- show all files (current & historical)
git log --all --pretty=format: --name-only | sort -u | uniq
- completely remove file from git (including history)
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch <filename>' --prune-empty --tag-name-filter cat -- --all
- remove backups
rm -rf .git/refs/original/
maybe replaced by
git for-each-ref --format="%(refname)" .git/refs/original/ | xargs -n 1 git update-ref -d
- delete unreachable commits
git reflog expire --expire=now --all
- start garbage collection
git gc --prune=now
git gc --aggressive --prune=now
- push changes
git push origin master --force
<note>If this step fails, you've to set denyNonFastforwards = false.</note>
snippets/git/remove-sensitive-data.txt · Zuletzt geändert: von 127.0.0.1
