直接上脚本

#!/bin/bash

# store the current dir
CUR_DIR=$(pwd)

UPDATE_ALL=0;

# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"

# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do  
    echo "";
    echo -e "\033[33m"+$i+"\033[0m";

    # We have to go to the .git parent directory to call the pull command
    cd "$i";
    cd ..;

    # Track all branches in target Git repository
    case $1 in
        -a|--all)
        UPDATE_ALL=1;
        ;;
    esac
    if [ $UPDATE_ALL -eq 1 ]; then
        git branch -r | grep -v '\->' | while read remote; do
            git branch --track "${remote#origin/}" "$remote";
        done

        git fetch --all;
        git pull --all;
    fi;

    # finally pull
    git pull;

    # lets get back to the CUR_DIR
    cd $CUR_DIR
done

echo -e "\n\033[32mComplete!\033[0m\n"  

方便起见, 可以在 /usr/local/bin/ 中, 新建一个可执行文件 update_git_repos, 并粘贴上述代码, 最后别忘记为文件添加可执行权限 chmod +x update_git_repos