b3hn4m
b3hn4m

Reputation: 75

what does git rm do as opposed to deleting by OS and git add

If we want to delete a file (say file1.txt) and stop the git repo to track it, it is said that we should use git rm file1.txt and then git commit -m "..." it. But deleting from the working directory by OS, rm file1.txt, add . and then git commit -m "..." do the same. what are their difference?

Upvotes: 0

Views: 1590

Answers (2)

Heirloom
Heirloom

Reputation: 35

By default, the git rm command deletes files both from the Git repository as well as the filesystem.

Deleting it manually using rm (file), won't remove it from the Git repo unless you do the following (after deleting that file):

git add *

git commit -m

Upvotes: 0

jthill
jthill

Reputation: 60235

There's no difference. git add of a tracked file you've removed from the work tree removes the index entry. A tracked file is what's in the work tree and the index record for it, there's nothing else, your sequence is exactly git rm.

Upvotes: 5

Related Questions