How can I delete a file from git repo?

git rm file1.txt
git commit -m "remove file1.txt"

if you want to remove the file only from the Git repository and not remove it from the filesystem, use:

git rm --cached file1.txt
git commit -m "remove file1.txt"

To push changes to remote repo

git push origin branch_name