git rm
CautionRemove from tracking
git rm [--cached] <file>
Deletes and stages; --cached untracks while keeping the file — for accidentally committed artifacts.
Examples
git rm --cached .envUntrack but keep the file
Syntax
git rm [--cached] [-r] <path>
Before you run it
Without --cached the file itself is deleted.
Related commands
- git addStage changes
- git cleanClean untracked
- git restoreRestore files
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store