Tesla
Tesla

Reputation: 813

removing files from git

I know I can remove a file from tracking and have it deleted with git rm <file>

or if I want to keep the file and just remove it from tracking I can use git rm --cached <file>

but what are the repercussions of this when I push it to the repository and other people pull from it? Makes sense that git rm --cached <file> would just remove it from tracking for everyone and they still have the file in their directory, but what about git rm <file>, will it just remove the file from tracking for other users or will it delete the actual file for them once they pull as well?

Upvotes: 0

Views: 87

Answers (2)

xdazz
xdazz

Reputation: 160943

The difference is:

rm <file>

This will only removes the file from the working tree.

git rm <file> 

This will removes file from the working tree and from the index (which is tracking by your words).

git rm --cached <file>

This will only remove file from the index.

If you remove file from the index, and push your commits, then the result is same, the file will be removed.

Upvotes: 4

ThiefMaster
ThiefMaster

Reputation: 318698

It will delete that file for them, too. Actually that will happen in both cases - no matter if you use --cached or not since what you eventually commit will be the same thing: The deletion of the file.

Upvotes: 1

Related Questions