Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get git to stop tracking a deleted file?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

‘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.

>Solution :

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)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading