Why use 'git rm' to remove a file instead of 'rm'?

On SVN, removing something from the filesystem directly (rather than using svn) created a load of headaches.

I haven't found this to be an issue when using git, but I notice that git has it's own rm implementation (git rm).

What is the difference between rm and git rm?


If you just use rm, you will need to follow it up with git add <fileRemoved>. git rm does this in one step.

You can also use git rm --cached which will remove the file from the index (staging it for deletion on the next commit), but keep your copy in the local file system.


Removing files using rm is not a problem per se, but if you then want to commit that the file was removed, you will have to do a git rm anyway, so you might as well do it that way right off the bat.

Also, depending on your shell, doing git rm after having deleted the file, you will not get tab-completion so you'll have to spell out the path yourself, whereas if you git rm while the file still exists, tab completion will work as normal.


git rm will remove the file from the index and working directory ( only index if you used --cached ) so that the deletion is staged for next commit.