Reputation: 23
I am trying to understand "git rm" command.
So I have a file Test.txt in my local directory/ current working directory
I did
git add .
git commit -m "1st commit"
Now, the file is added to staging area and committed to local repo.
If I do git rm Test.txt
and do git status
, I see
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: Test.txt
ls
also doesn't show the file, So the file has been deleted from both current working directory and staging area. But if I see the files committed git ls-tree --full-tree -r --name-only HEAD
, I still see the file.
Does it mean git rm
removes the file only from current working directory and staging area but not from local repo?
Upvotes: 2
Views: 49
Reputation: 310983
git rm
stages a change to remove a file, similarly to how git add
stages a change to add or modify a file. After you commit this change, you'll no longer see the file in git ls-tree
.
Upvotes: 3