gitgit-pushgit-pullgit-untracked

Git untrack and push


Situation: I untrack some files keeping them locally. Files are removed from the index and kept in working tree. Then I commit and push to remote. Files will be deleted from remote repository.

What will happen to other people when they pull? Will their local file be deleted (like remote) or will they keep their local copy, untracked (like my working tree)?


Solution

  • If other people pull the branch locally then, their local files will be deleted like remote since the files are deleted from remote.


    git rm --cached remove the file(s) from staging area, so the file(s) become untracked (not known/handle by git anymore). After Commit, Push the file is deleted from the remote.

    Like if you just create a new file a.txt but not Add, Commit, Push to remote (a.txt is a untracked file), then a.txt is totally unknown to other people when pulling locally.