When untrack a file in the git repository, use git rm -r --cached .
. This will not remove the ever tracked file in local storage, but when other developers fetc
On Machine A:
git rm -r --cached .
Above command will remove files from the index (both README.md and file_not_to_track). At this time, the index is empty. However, file_not_to_track is still exists on file system.
--cached: Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.
git add .
With add action, git just added only README file. (file_not_to_track has been ignored).
On Machine B:
2 files changed, 1 insertion(+), 1 deletion(-)
With pull action, git recognizes that file_not_to_track is gone. Git perform an detele action.
git rm --cached
tracks a change of removing the file from git, but does not remove the local copy. Running ls
locally will still show the local file, but if you pull from another machine, the change of removing that file will be applied, and the file removed.
This is how option --cached works, it removes the file from the git index. Working tree files will be left alone. However, Git will no more track this file in your local repository.
Look here for the --cached option:
https://git-scm.com/docs/git-rm