Skip to content

Instantly share code, notes, and snippets.

@ubuntupunk
Created September 24, 2024 10:34
Show Gist options
  • Save ubuntupunk/9ee38cfe7e21a505985861fc50be8a3a to your computer and use it in GitHub Desktop.
Save ubuntupunk/9ee38cfe7e21a505985861fc50be8a3a to your computer and use it in GitHub Desktop.
prune accidental key committed to repo
$ mkdir repo_cleanup
$ cd repo_cleanup
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY .
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch key.txt" \
--prune-empty --tag-name-filter cat -- --all
$ echo "key.txt" >> .gitignore
$ git add .gitignore
$ git commit -m "Add key.txt to .gitignore"
$ git push origin --force --all
$ git push origin --force --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment