Skip to content

Instantly share code, notes, and snippets.

@pad92
Last active November 22, 2022 13:46
Show Gist options
  • Save pad92/82bc97c7092d6eb49835ea2ce9867825 to your computer and use it in GitHub Desktop.
Save pad92/82bc97c7092d6eb49835ea2ce9867825 to your computer and use it in GitHub Desktop.
Recursive git prune
#!/bin/sh
for REPO in $(find $(pwd) -type d -name .git | sed 's@/.git@@g'); do
echo -ne "- ${REPO}"
PRUNE=$(git --git-dir=${REPO}/.git remote prune origin 2&>1 )
if [ $? -ne 0 ]; then
echo -ne "\tERROR\n"
echo "$(date +"%Y%m%d-%H%M") ERROR: ${REPO}" >> prune.log
echo "${PRUNE}" >> prune.log
echo "" >> prune.log
else
echo -ne "\tOK\n"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment