Created
July 2, 2025 12:33
-
-
Save dwisiswant0/3159052420f2f4e54500578cba242983 to your computer and use it in GitHub Desktop.
gitleaks-unreachable-commits
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 | |
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then | |
echo "This is not a git repo." | |
exit 1 | |
fi | |
git fsck --full --no-reflogs --unreachable | | |
grep 'unreachable commit' | | |
awk '{print $3}' | | |
while read commit; do | |
GITLEAKS="$(git show ${commit} | gitleaks stdin -v 2>/dev/null)" | |
if [ $? -eq 1 ]; then | |
echo "${commit}" | |
echo "${GITLEAKS}" | |
echo "---------------------------------" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment