Reputation: 12289
So I am working on a project and add a gitignore file to prevent some sensitive data from being included only it fails to work as expected and now I have pushed it. Is there a way to delete that from the remote repository so there is no evidence of it in the history?
Upvotes: 3
Views: 3189
Reputation: 1572
If the sensitive information was introduced before the most recent commit and you would like to remove it from the full tree, I recommend git BFG.
See: https://help.github.com/articles/removing-sensitive-data-from-a-repository/
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-branch command or the BFG Repo-Cleaner.
Also, https://rtyley.github.io/bfg-repo-cleaner/
The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data >out of your Git repository history:
- Removing Crazy Big Files
- Removing Passwords, Credentials & other Private data
Upvotes: 0
Reputation: 1657
You could revert the changes locally
git commit --amend
or
git reset <last-hash>
and then do a
git push -f
but this should only be done
if you:
Tip:
Be very careful, that the repository is in the state you want it to be, before you push -f
, because changing history is generally a big no-no for various good reasons
Upvotes: 1