Untrack Already Committed Files
Once files are already tracked (committed), simply adding them to .gitignore won’t stop Git from tracking them — you have to remove them from the index while keeping them on disk.
🧩 Step-by-step
1. Make sure your .gitignore is correct
Example:
.obsidian/workspace.json
.obsidian/plugins/obsidian-git/data.json
.trash/
cache/
tmp/
Check it:
| |
2. Remove ignored files from the index
Untrack them (without deleting locally):
| |
3. Re-add everything (Git will now skip ignored files)
| |
4. Commit the cleanup
| |
5. Push the changes
| |
💡 Explanation
--cached= remove from the Git index, not from your disk.- After this, Git will no longer track or commit those
.gitignored files.
✅ Optional checks
See what’s still tracked that shouldn’t be:
| |
Confirm a file is now ignored:
| |
🧠 Tip
You can confirm that .gitignore rules work before committing by running:
| |
Only non-ignored files should appear as changes.