Skip to content

Instantly share code, notes, and snippets.

View nouxinf's full-sized avatar
🚉
i like trains

nouxinf

🚉
i like trains
  • The Scratch Channel
  • Scotland
  • 06:12 (UTC)
View GitHub Profile
@nouxinf
nouxinf / git-ignore.ps1
Last active January 2, 2026 17:51 — forked from jeffjohnson9046/git-ignore.sh
Remove unwanted files from a git repo AFTER adding a .gitignore. The files will remain on disk.
## I just ran into this after initializing a Visual Studio project _before_ adding a .gitignore file (like an idiot).
## I felt real dumb commiting a bunch of files I didn't need to, so the commands below should do the trick. The first two commands
## came from the second answer on this post: http://stackoverflow.com/questions/7527982/applying-gitignore-to-committed-files
# See the unwanted files:
git ls-files -ci --exclude-standard
# Remove the unwanted files:
git ls-files -ci --exclude-standard |
ForEach-Object { git rm --cached $_ }