Search code examples
gitgit-workflow

How do you alter an object's historical content in a git repository?


I have a local git repository that I eventually plan on publishing as open source. I recently noticed that one of the files has a password in it. Obviously, I need to strike that password from the entire history before I publish the repository.

A: Is there a way to access and modify the history for all revisions to that particular file?

B: I guess one alternative is to simply publish a clean version of the HEAD.


Solution

  • git rm <file>
    git-filter-branch --index-filter 'git update-index --remove <file>' master
    

    This should remove the file from all revisions.

    Source: http://help.github.com/removing-sensitive-data/

    Though if you are really worried, just upload a new, clean repo without the file.