Git Cheatsheet - Quick Git Command Reference

Quick reference for common Git commands. Search, copy, and use Git commands instantly.

Share
Back to Git Cheatsheet

git rm

Remove files from working tree and staging area

Syntax

git rm [options] [--] <file>...

Common Options

OptionDescription
-rRecursive remove for directories
--cachedRemove from staging only, keep working tree
-f, --forceForce removal
-n, --dry-runDry run, show files to be removed
-q, --quietQuiet mode

Examples

git rm file.txt

Remove file and stage deletion

git rm --cached file.txt

Stop tracking but keep local file

git rm -r old-directory/

Recursively remove directory

git rm "*.log"

Remove all .log files

Related Tools

More Code & Dev Tools