Skip to content

Instantly share code, notes, and snippets.

@jgmuchiri
Created July 30, 2020 11:48
Show Gist options
  • Save jgmuchiri/13a05b475f361211a603110608eaf55f to your computer and use it in GitHub Desktop.
Save jgmuchiri/13a05b475f361211a603110608eaf55f to your computer and use it in GitHub Desktop.
Add this to your .bashrc to permanently remove a file from git repo and history
gitremove(){
echo "Enter file to remove"
read FILE
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch $FILE' --prune-
empty --tag-name-filter cat -- --all
git push origin master -f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment