Git untrack and push

1.4k views Asked by At

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)?

2

There are 2 answers

4
Sajib Khan On BEST ANSWER

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.

0
Heliospeed On

To start ignoring the changes to the file

git update-index --assume-unchanged path/to/file

To start keeping track again

git update-index --no-assume-unchanged path/to/file