Created
October 23, 2015 18:03
-
-
Save ryanemmm/388a7fc3ea3d33f72e04 to your computer and use it in GitHub Desktop.
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
# from: http://blog.pivotal.io/labs/labs/a-simple-way-to-detect-unused-files-in-a-project-using-git | |
# `git ls-files` -> get a list of files from a directory | |
# `git grep` + loop -> check for reference to file in repo | |
# list or remove the file | |
# dry run: just list the unused files | |
for FILE in $(git ls-files ./img); do | |
git grep $(basename "$FILE") > /dev/null || echo "would remove $FILE" | |
done | |
# for real: git rm the file | |
for FILE in $(git ls-files ./img); do | |
git grep $(basename "$FILE") > /dev/null || git rm "$FILE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment