I am reading book Git Pro and it says:
To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The
git rm
command does that, and also removes the file from your working directory so you don’t see it as an untracked file the next time around.
And the next paragraph talks about git rm -f
:
If you modified the file and added it to the staging area already, you must force the removal with the
-f
option. This is a safety feature to prevent accidental removal of data that hasn’t yet been recorded in a snapshot and that can’t be recovered from Git.
What I don't understand is in both paragraph, they are talking about removing file from the same area(staging I guess, place where git
add screenshot after git add .
).
If both command is used to remove file from staging area, then what is the difference?
git rm -f
(or--force
) overrides the up-to-date check. If no-f
is supplied,git rm
will refuse to remove a file that's modified since last commit, butgit rm -f
will proceed removal.