Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all traces of a single file in git [duplicate]

Tags:

git

I recently noticed that I had a file with sensitive information under version control in git. I have now added this file to my .gitignore list, but how can I remove all mention of it from my commit history without touching anything else? i.e., I don't want to just delete my .git directory.

like image 347
bqui56 Avatar asked Jan 19 '14 03:01

bqui56


2 Answers

Try this guide on the GitHub help site: https://help.github.com/articles/remove-sensitive-data

Specifically:

git filter-branch --force --index-filter \
  'git rm --cached --ignore-unmatch Rakefile' \
  --prune-empty --tag-name-filter cat -- --all
like image 192
twe4ked Avatar answered Oct 08 '22 02:10

twe4ked


Good question. This github remove-sensitive-data and this remove-sensitive-files-and-their-commits-from-git-history explain it.

like image 27
Ethan Fang Avatar answered Oct 08 '22 04:10

Ethan Fang