How to Untrack in Git - Untrack Previously Committed Files with .gitignore

To untrack a single file, ie stop tracking the file but not delete it from the system use:

git rm --cached filename

To untrack every file in .gitignore:

First commit any outstanding code changes, and then run:

git rm -r --cached

This removes any changed files from the index(staging area), then run:

git add .

Commit it:

git commit -m ".gitignore is now working"

To undo git rm --cached filename, use git add filename

2 Likes