Created
November 4, 2018 13:24
-
-
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.
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
| #!/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