Working areas in git
In a git project, there are 4 storage areas and you move the data across these areas:
working area, index, repository and stash.
Working area = your actual files and folders
Index = an area between the working area and the repository. It is stored in index directory, under .git
Repository = the .git directory with the objects database represented by the objects directory in .git
You cannot move directly information from the working area to the repository. You first move it to the index, usually called the staging area.
You add changes from the working area to the index and then you commit changes from the index to the repository.
Move data from left to right:
When you commit a file, you don't just move the content from the index to the repository. Beisdes, it changes the repository - create a new commit object, copied other objects and updated the current branch to point to the new commit.
By contrast, add just moves data from the working area to the index, without altering the repository. This applies also when the file is deleted.
Move data from right to left:
When you checkout, you first affect the repository by changing the current commit, the HEAD will point to a different commit, and second copy the data from the repository to the working area and index.
git rm - can be used when you have a file on the working area and the index, you haven't yet committed the file and you want to remove that file from both the working area and the index. If you want rm to behave as an opposite of git add, the pass the --cached argument and then it will remove the file from the index, but it will remain in the working area.