而不是做:
git push origin --all && git push nodester --all && git push duostack --all
有没有办法只用一个命令就能做到这一点呢?
谢谢:)
发布于 2013-09-07 22:27:04
要将所有分支推送到所有远程数据库:
git remote | xargs -L1 git push --all
或者,如果您想要将特定分支推送到所有远程:
将master
替换为您要推送的分支。
git remote | xargs -L1 -I R git push R master
(额外的)为命令创建一个git别名:
git config --global alias.pushall '!git remote | xargs -L1 git push --all'
现在,运行git pushall
会将所有分支推送到所有远程。
发布于 2012-10-27 23:15:20
作为编辑.git/config文件的CLI替代方法,您可以使用以下命令:
# git remote add all origin-host:path/proj.git
# git remote set-url --add all nodester-host:path/proj.git
# git remote set-url --add all duostack-host:path/proj.git
同样的git push all --all
在这里也可以工作。
您已经完成了与答案#1相同的操作。您只是使用命令行完成了该操作,而不是直接编辑配置文件。
发布于 2013-01-25 03:09:20
我编写了一个简短的bash函数,以便在一个调用中推送到多个遥控器。您可以指定一个遥控器作为参数,多个遥控器以空格分隔,或者不指定任何遥控器以将其推送到所有遥控器。
这可以添加到您的.bashrc或.bash_profile中。
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
}
例如:假设您的存储库有3个遥控器: rem1、rem2和rem3。
# Pushes to rem1
GitPush rem1
# Pushes to rem1 and rem2
GitPush rem1 rem2
# Pushes to rem1, rem2 and rem3
GitPush
https://stackoverflow.com/questions/5785549
复制相似问题