How to remove unwanted file from my Git history

Git is cool, but often we accidentally back up things we don’t want in the first place, such as enormous huge binary file or sensitive information. Here is git command to the help.

$git filter-branch --index-filter 'git rm --cached --ignore-unmatch *.epub *.pdf’ HEAD    
$rm -rf .git/refs/original/ && git reflog expire --all &&  git gc –aggressive 

 

finally give it a force push to github or any remote server.

$git push origin master --force

 

Advertisements