Generated image
|| #resource #git

Git: Delete file after ignoring it

Delete a file tracked by git after adding it to the .gitignore file

When you update the .gitignore file to start ignoring a new file, that file will not be removed on the next commit and will instead continue to be tracked. The process to actually remove a newly ignored file is a bit un-intuitive.

git rm --cached <file>

Replace <file> with the path to the file to be removed

Or, for a folder:

git rm -r --cached <folder>

Replace <folder> with the path to the folder to be removed

This will tell git to remove these files from its internal cach and their removal can be included in the next commit.

Related


Maybe try another one?

Encrypted LUKS Container Create an encrypted volume on linux using LUKS
2022.05.24
Intro to Server Monitoring How to monitor your server with Prometheus and Grafana
2019.11.01
My takeaways from Medium Day 2024
2024.08.18