Reputation: 75
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
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
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