Home > Net >  How to get git to stop tracking a deleted file?
How to get git to stop tracking a deleted file?

Time:01-03

When I type in git status I get the following:

On branch master Changes to be committed: (use "git restore --staged ..." to unstage)
new file: MyDeletedFile.hpp

Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git restore ..." to discard changes in working directory)
deleted: MyDeletedFile.hpp

'MyDeletedFile.hpp' has been deleted. How do I get git to stop showing this in git status? I'm not sure how to add these changes to a commit since the file doesn't exist.

CodePudding user response:

You can record to the index the deletion of that file (git add -- MyDeletedFile.hpp), and all you need to do is a git commit.

Once the commit is done, Git will no longer show that file in the status.

The OP Rahul Iyer mentions in the comments having to do two commits, the second one handling the deleted file. That could happen when the deleted file has not the same case (mydeletedfile.hpp vs. MyDeletedFile.hpp)

  •  Tags:  
  • git
  • Related