Name

rm

Synopsis

git rm [-f] [-r] -- path ...

Remove files from the work tree and index. They will be permanently removed when you run git commit.

With -f, forces removal of a file even if it doesn’t match HEAD. With -r, removes entire directories and all their contained files.

Options

-f (force)
-r (recursive)
--cached (ignore work tree)
-n, --dry-run

Examples

To remove the mylib directory:

$ git rm -r mylib
rm 'mylib/test1.c'
rm 'mylib/test2.c'

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.