function GitPush {
REMOTES=$@
# If no remotes were passed in, push to all remotes.
if [[ -z "$REMOTES" ]]; then
REM=`git remote`
# Break the remotes into an array
REMOTES=$(echo $REM | tr " " "\n")
fi
# Iterate through the array, pushing to each remote
for R in $REMOTES; do
echo "Pushing to $R..."
git push $R
done
}
示例:假设您的repo有3个遥控器:rem1、rem2和rem3。
# Pushes to rem1
GitPush rem1
# Pushes to rem1 and rem2
GitPush rem1 rem2
# Pushes to rem1, rem2 and rem3
GitPush