Looking for github Answers? Try Ask4KnowledgeBase
Looking for github Keywords? Try Ask4Keywords

githubRemoving sensitive data or large files


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.


  1. Tell your collaborators to rebase, not merge, any branches they created off of your old (tainted) repository history. One merge commit could reintroduce some or all of the tainted history that you just went to the trouble of purging.

  2. After some time has passed and you're confident that git filter-branch had no unintended side effects, you can force all objects in your local repository to be dereferenced and garbage collected with the following commands (using Git 1.8.5 or newer):

    git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin

    git reflog expire --expire=now --all

    git gc --prune=now