1. Delete the file from the repository
git rm filename
git commit
The file is removed from the repository
2. If you delete it by mistake, restore the mistakenly deleted file to the latest version
$ git checkout --filename
But be careful, you can only restore the file to the latest version, you will lose what you modified since the last commit .