Removing a file from git staging (index) area.
Assume git add sample file => for adding the file to git staging area.
Check the git status command
Use git rm for removing the content from working tree and index of the repository.
Examples are,
git rm --cached sample file
The command given above will remove the file from staging area but still available in working copy.
git rm -f sample file
The above command will remove the file from working copy as well as from staging area.
Note:
Unless the file is added to the staging area, git rm command won’t execute on that file.