3 git symbolic-ref -q HEAD >/dev/null && exit
8 branches=(`git branch --points-at=HEAD | tail -n +2`)
10 if [ "${#branches[*]}" -eq 0 ]; then
11 branches=(`git config -f $toplevel/.gitmodules --get submodule.$name.branch`)
14 if [ "${#branches[*]}" -eq 0 ]; then
15 branches=(`git for-each-ref --format="%(refname:lstrip=3)" --points-at=HEAD refs/remotes | sort -u`)
18 if [ "${#branches[*]}" -eq 0 ]; then
19 echo "Cannot find a branch" >&2
20 elif [ "${#branches[*]}" -eq 1 ]; then
21 git checkout "${branches[0]}"
23 echo "Too many branches" >&2