Last active
April 27, 2025 09:47
-
-
Save floydnoel/2f4ab07460c2717e84dbad933f208f8a to your computer and use it in GitHub Desktop.
Remove all files from a Git repo based on the .gitignore file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Cleaning up any git ignored files..." | |
# copy and paste the line below to get the same results as running this script | |
git rm --cached `git ls-files -ic --exclude-from=.gitignore` | |
echo "Finished clean up." | |
# source: https://stackoverflow.com/questions/13541615/how-to-remove-files-that-are-listed-in-the-gitignore-but-still-on-the-repositor/13541721 |
For Unreal Engine, I had a lot of files, so I used this:
git ls-files -ic --exclude-from=.gitignore | xargs git rm --cached
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works perfectly. Thank you