Skip to content

Instantly share code, notes, and snippets.

@Tantas
Created August 18, 2014 19:33
Show Gist options
  • Save Tantas/d49b09bbd29a40f06123 to your computer and use it in GitHub Desktop.
Save Tantas/d49b09bbd29a40f06123 to your computer and use it in GitHub Desktop.
List the repository remotes found in a supplied directory
#!/bin/sh
# List the repository remotes found in a supplied directory.
# List the available repositories if no argument
if [[ "$#" -ne 1 ]]; then
echo "Provide a directory containing repositories."
exit -1
fi
# Find all files in the provided directory
# Check for the git remotes, do not display errors
# Remove every second line (push/pull)
# Print the second column
find $1 -depth 1 -exec git --git-dir={}/.git remote -v 2> /dev/null \; | awk 'NR%2==0' | awk '{print $2 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment