9

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.

Tyler
  • 829
  • 11
  • 26

1 Answers1

3

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.

Leo Correa
  • 19,131
  • 2
  • 53
  • 71
  • 1
    An explanation of what that actually does would be great. – user3467349 Jul 08 '14 at 07:44
  • 5
    The linked article explains how to remove a file. The OP's question title says to not remove a file. – Tyler Collier Mar 14 '15 at 16:32
  • @TylerCollier if you read my answer it states not to add the file to `gitignore` since that will take it out of version control. This will remove the file from history thus allowing the sensitive data to be removed. – Leo Correa Mar 15 '15 at 00:14
  • 5
    The OP already knows how to do that: `I'm only seeing how to remove the file itself from version control and clear its history.` I think he wants to remove only the sensitive information from the history, but not the history itself. – Tyler Collier Mar 15 '15 at 05:19
  • Holy crap. Whatever happened to a simple right click remove history. Insanely complex. Can't get it to work. Keep getting messages stating it remains unchanged. – Koen Zomers Jun 09 '15 at 11:08