Remove unwanted files from a git repo AFTER adding a .gitignore.


# See the unwanted files:
git ls-files -ci --exclude-standard

# Remove the unwanted files: 
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached

# Commit changes
git commit -am "Removed unwanted files marked in .gitignore"

# Push
git push origin master # or whatever branch you're on

source


Created 2026-07-30 11:37:30 UTC by Mich3l
Updated 2026-07-31 09:28:01 UTC by Mich3l