git: remove secrets from history

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 to edit where you want to edit
  • amend the commit with git commit --amend
  • and continue with git rebase --continue

2. if you have committed and pushed to GitHub

Upload a new Github Repo from the command line

1. create the repo via curl

Replace <this>:

2. upload

Assuming you’ve created your git repo locally, added and committed then:

3. check

It should be at: