Let’s say you’ve accidentally added a password into git. Here’s how you remove it:
1. if you have only committed locally
a. and it’s your last commit
- just edit the file and run
git commit -a --amend
b. and it’s a previous commit
- do an interactive rebase with
git rebase -i origin/master
- change the
pick
toedit
where you want to edit - amend the commit with
git commit --amend
- and continue with
git rebase --continue
https://stackoverflow.com/questions/872565/remove-sensitive-files-and-their-commits-from-git-history
2. if you have committed and pushed to GitHub
https://blog.ostermiller.org/git-remove-from-history
https://blog.tinned-software.net/remove-files-from-git-history/