Remove file from git version control without deleting it from the filesystem

How can I remove a file from the git tree without deleting it?

It is easy to git add an untracked file to include it by the next commit, however I do not find out how to to remove the file to have it "untracked" again by another commit.


Easy. Just use git rm --cached on the file 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

As explained in the official Git git-rm documentation:

--cached

Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.