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.
1 Answer
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.txtAs explained in the official Git git-rm documentation:
1--cached
Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.