Skip to content

Instantly share code, notes, and snippets.

@devantler
Last active December 3, 2022 18:48
Show Gist options
  • Save devantler/59692d4a77ed7611a71dd264bc71ede9 to your computer and use it in GitHub Desktop.
Save devantler/59692d4a77ed7611a71dd264bc71ede9 to your computer and use it in GitHub Desktop.
Remove committed files that are in .gitignore

Linux/MacOS: git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached

Windows (PowerShell): git ls-files -ci --exclude-standard | % { git rm --cached "$_" }

Windows (cmd.exe): for /F "tokens=*" %a in ('git ls-files -ci --exclude-standard') do @git rm --cached "%a"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment