Skip to content

Instantly share code, notes, and snippets.

@chrisguest75
Created November 4, 2018 13:24
Show Gist options
  • Select an option

  • Save chrisguest75/7e1ef1911bf0554f7f9369fa252b112e to your computer and use it in GitHub Desktop.

Select an option

Save chrisguest75/7e1ef1911bf0554f7f9369fa252b112e to your computer and use it in GitHub Desktop.
Output a tabulated list of child git repo remote urls. When you need to find where you cloned or pushed a repo from. Path it.
#!/usr/bin/env bash
function showremote() {
repopath="$(dirname "$1")"
pushd ${repopath} > /dev/null
url=$(git ls-remote --get-url 2>/dev/null)
result=$?
if [ $result -ne 0 ]; then
url="No remote configured"
fi
echo "${repopath}, ${url}"
popd > /dev/null
}
function print_subdir_remotes_columns(){
output=$(find ./* -name ".git" -print | while read file; do showremote "$file"; done)
echo "$output" | column -t -s,
}
print_subdir_remotes_columns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment