Created
August 3, 2012 16:02
-
-
Save EpocSquadron/3248986 to your computer and use it in GitHub Desktop.
Remove files from a repo that should be ignored but you dont neccesarily want to delete from filesystem.
This file contains 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 | |
# Regexes matching files and folders in the gitignore that should never be in a repo. | |
GITIGNORE_REGEXES=( ".+\.(diff|err|orig|log|rej|swo|swp|vi|sass-cache|sublime-project|sublime-workspace|komodoproject|esproj|espressostorage|rbc)" ".+\~" "\.\/\.(DS_Store|_.+|cache|project|settings|tmproj|komodotools|hg|svn|CVS|idea)" "\.\/(nbproject|Thumbs\.db|_notes|dwsync\.xml)" ) | |
# Get rid of them in git, leave them in filesystem. | |
for REGEX in "${GITIGNORE_REGEXES[@]}"; do | |
FILES=`find -E . -iregex "$REGEX" | sed 's/^..//;' | tr '\n' ' '` | |
echo "## Regex: $REGEX" | |
if [ ! "$FILES" = "" ]; then | |
echo "## Files: $FILES" | |
git rm -rf --cached --ignore-unmatch $FILES | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment