To remove a file from the current commit or HEAD but if you want remove entirely from the repository’s history then you need to run couple of commands.
git filter-branch --index-filter \
'git rm -rf --cached --ignore-unmatch path_to_file' HEAD
This will rewrite your
git
history to remove the file