remove sensitive data but not file from git history

git, github, version-control

Solution

You might want to look at this article https://help.github.com/articles/remove-sensitive-data

Pretty much says this command

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch Rakefile' \
  --prune-empty --tag-name-filter cat -- --all

Will remove the history of `Rakefile` from git. However, they go ahead and add that file to their gitignore. You should probably skip that part since you want to keep the file in version control.

Problem

I have a file that once contained sensitive config information. I move that config info out into another file that isn't under version control. I want to keep the other file under version control, but I want to remove its history because one can easily browse the source on github and find the sensitive information in previous commits. What's the best way to do this? I'm only seeing how to remove the file itself from version control and clear its history. A little new to git, so pardon the newbieness.

Original source

Related problems