#!/bin/bash # from https://unix.stackexchange.com/questions/183361/get-git-branch-from-several-folders-repos # function git_branches() # { if [[ -z "$1" ]]; then echo "Usage: $0 " >&2 return 1 fi if [[ ! -d "$1" ]]; then echo "Invalid dir specified: '${1}'" return 1 fi # Subshell so we don't end up in a different dir than where we started. ( cd "$1" for sub in *; do [[ -d "${sub}/.git" ]] || continue echo "$sub [$(cd "$sub"; git branch | grep '^\*' | cut -d' ' -f2)]" done ) #}