git rm Remove files from the repository and your folder

Deletes a file and stages the deletion in one step, so the next commit records that the file is gone. It also stops Git tracking the file if you keep it.

Synopsis

git rm [OPTION]... FILE...

Common options

Option or formWhat it does
--cachedStop tracking the file but leave it on your disk
-rRemove a folder and its contents
-fForce removal even when the file has local changes
-n, --dry-runShow what would be removed without doing it

Examples

Delete a file and stage it
git rm old-notes.txt
rm 'old-notes.txt'
Stop tracking a file but keep it
git rm --cached .env
Delete a folder
git rm -r build/
Preview first
git rm -rn build/

Notes

See also

Last reviewed 2026-10-09.