Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)

Say I have a file in my git repository called foo.

Suppose it has been deleted with rm (not git rm). Then git status will show:

Changes are not staged for commit:

deleted: foo

How do I stage this individual file deletion?

If I try:

git add foo

It says:

'foo' did not match any files.

1 Answer

0 votes
by (50.2k points)

For this question, you can use:

git rm foo 

This is used to stage the file for deletion. 

This will delete the file from the file system. and restore it from git.

And to stage the file for deletion (without deleting it from the file system), use:

 git rm --cached foo


Browse Categories