git rm <pathname>

Remove a file or a directory from the file system and from git's index

By using git rm instead of just deleting the files from the system, you avoid having to add the deleted files to the "staging area".

If you only want to delete files in the current commit, you will save a step

rm ./components/Button.tsx
git add .
git commit -m "chore: deleted Button component"

becomes:

git rm ./components/Button.tsx
git commit -m "chore: deleted Button component"

Sign in to enable bookmarking, reminders, progress-tracking and more...