而不是做:
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会将所有分支推送到所有远程。
发布于 2011-04-26 11:34:19
使用多个指向其名称的存储库URL创建一个all remote:
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。
这是它在.git/config中的外观
[remote "all"]
url = origin-host:path/proj.git
url = nodester-host:path/proj.git
url = duostack-host:path/proj.git发布于 2015-07-15 15:37:46
如果您希望始终推送到repo1、repo2和repo3,但始终仅从repo1拉取,请将远程‘源’设置为
[remote "origin"]
url = https://exampleuser@example.com/path/to/repo1
pushurl = https://exampleuser@example.com/path/to/repo1
pushurl = https://exampleuser@example.com/path/to/repo2
pushurl = https://exampleuser@example.com/path/to/repo3
fetch = +refs/heads/*:refs/remotes/origin/*在命令行配置:
$ git remote add origin https://exampleuser@example.com/path/to/repo1
$ git remote set-url --push --add origin https://exampleuser@example.com/path/to/repo1
$ git remote set-url --push --add origin https://exampleuser@example.com/path/to/repo2
$ git remote set-url --push --add origin https://exampleuser@example.com/path/to/repo3如果您只想从repo1拉取,但推送到特定分支specialBranch的repo1和repo2
[remote "origin"]
url = ssh://git@aaa.xxx.com:7999/yyy/repo1.git
fetch = +refs/heads/*:refs/remotes/origin/*
...
[remote "specialRemote"]
url = ssh://git@aaa.xxx.com:7999/yyy/repo1.git
pushurl = ssh://git@aaa.xxx.com:7999/yyy/repo1.git
pushurl = ssh://git@aaa.xxx.com:7999/yyy/repo2.git
fetch = +refs/heads/*:refs/remotes/origin/*
...
[branch "specialBranch"]
remote = origin
pushRemote = specialRemote
...参见https://git-scm.com/docs/git-config#git-config-branchltnamegtremote。
https://stackoverflow.com/questions/5785549
复制相似问题