Take the 2-minute tour ×

I need to move current and ALL past revisions of a file in my repository, and then replace them with a new file. Basically, without thinking, I forgot (and continuously forgot) to remove the mysql password for the database connection file, and would like to remove any traces of this.

The simplest fix would be to change the mysql password and from this point on, do not include the password in the file, however, I'd like to just clean up the revision history.

share|improve this question
Not sure how to do this, so I won't add this as an answer, but I'm concerned given the distributed nature of Git that even if you push a new file to a remote, all the other remotes will still have the old one. –  Michael Shimmins Jan 22 '11 at 5:39
It's a pretty personal project and non of the code has been distributed, so this is not an issue. However, if I end up making this public source, it will then be an issue. –  drewrockshard Jan 22 '11 at 5:49
add comment

2 Answers

up vote 4 down vote accepted

See the previous answer: How do I remove sensitive files from git's history

git filter-branch to the rescue: http://git-scm.com/docs/git-filter-branch

Beware that this will change all of the SHA-hashes of your commits, but that's OK if it's a personal project.

share|improve this answer
This worked perfectly. Thanks. –  drewrockshard Jan 23 '11 at 5:03
add comment

Github has a help section dedicated to this issue. I actually used it before and find it very useful.

share|improve this answer
add comment

Your Answer


