Use Git's own file commands so deletions and renames get staged correctly.
git rm <file> — delete the file from disk and stage the deletion. Same as deleting in your editor plus git add.
git rm --cached <file> — keep the file on disk but stop tracking it. The classic fix for "I committed .env and now it's in history":
echo .env >> .gitignore
git rm --cached .env
git commit -m "chore: untrack .env"
git mv <old> <new> — rename a tracked file. Git detects renames anyway based on content similarity, but git mv makes the intent explicit and keeps the rename in one commit.