Sometimes we may end up adding files in our commit which we never intended to commit. Nothing to worry if you come across a scenario. The command git rm will remove it from both your staging area (index), as well as your file system (working tree), which may not be what you want. We can use git rm --cached on the file if you want to remove from the version control cache but do not want to remove/delete from your filesystem. So if you wanted to remove foo.txt from version control like this just run this command: git rm --cached foo.txt We can also use below git commands to achieve the same result: git reset filename          The above command is used to undo the local changes. Git reset operates on "The Three Trees of Git". These trees are the Commit History ( HEAD ), the Staging Index, and the Working Directory This is a common yet one of the most important Git coding interview questions and answers for experienced professionals, don't miss this one.