Last active
September 21, 2020 13:40
-
-
Save cedricbdev/a81bd2ca73a90f7f7ae512e45c7ba1e7 to your computer and use it in GitHub Desktop.
A simple way to detect unused files in a project using git
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/sh | |
for FILE in $(git ls-files ./img); do | |
# echo files that should be removed | |
# git grep $(basename "$FILE") > /dev/null || echo "would remove $FILE" | |
# remove files that should be removed | |
git grep $(basename "$FILE") > /dev/null || git rm "$FILE" | |
done | |
# credit: https://tanzu.vmware.com/content/blog/a-simple-way-to-detect-unused-files-in-a-project-using-git | |
# Do not forget to add execution rights to the file: > chmod +x remove-images.sh | |
# Run the script with: > ./remove-images.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment