做空者:有没有一种方法可以让git回购推送到远程回购列表(而不是一个单一的“来源”)中并从中提取?

长篇大论:当我在多台电脑上开发一个应用程序时,我经常会遇到这样的情况,这些电脑具有不同的连接能力——比如,一台笔记本电脑在运输途中,一台电脑“a”在某个位置,另一台电脑则“B”在另一台位置。此外,笔记本电脑可能只与“A”或“B”连接,有时两者都连接。

我希望git始终“拉”到它当前可以连接的所有计算机,这样从一台机器跳到另一台机器,继续无缝工作就更容易了。


当前回答

自git1.8(2012年10月)以来,您可以通过命令行执行此操作:

git remote set-url origin --push --add user1@repo1
git remote set-url origin --push --add user2@repo2
git remote -v

然后git push将推到user1@repo1,然后推到user2@repo2.

其他回答

自git1.8(2012年10月)以来,您可以通过命令行执行此操作:

git remote set-url origin --push --add user1@repo1
git remote set-url origin --push --add user2@repo2
git remote -v

然后git push将推到user1@repo1,然后推到user2@repo2.

您可以通过以下方式添加遥控器:

git remote add a urla
git remote add b urlb

然后,要更新所有回购,请执行以下操作:

git remote update

我想在VSO/TFS中工作,然后在准备好后向GitHub公开推送。在私人VSO中创建的初始回购。当需要添加到GitHub时,我做到了:

git remote add mygithubrepo https://github.com/jhealy/kinect2.git
git push -f mygithubrepo master

像冠军一样工作。。。

要进行健全性检查,请发出“gitremote-v”以列出与项目关联的存储库。

C:\dev\kinect\vso-repo-k2work\FaceNSkinWPF>git remote -v
githubrepo      https://github.com/jhealy/kinect2.git (fetch)
githubrepo      https://github.com/jhealy/kinect2.git (push)
origin  https://devfish.visualstudio.com/DefaultCollection/_git/Kinect2Work (fetch)
origin  https://devfish.visualstudio.com/DefaultCollection/_git/Kinect2Work (push)

简单的方法,对我有用…希望这能帮助到某人。

我将两个单独的pushurl添加到.git配置文件中的远程“源”。当我运行git push origin“branchName”时,它将运行并推送到每个url。不确定是否有更简单的方法来实现这一点,但这对我自己来说是可行的,既可以推送Github源代码,也可以推送My.visualStudio源代码。

[remote "origin"]
  url = "Main Repo URL"
  fetch = +refs/heads/*:refs/remotes/origin/*
  pushurl = "repo1 URL"
  pushurl = "reop2 URl"

我冒昧地扩大了诺娜·乌比兹的答案;只需将此添加到~/.bashrc:

git-pullall () { for RMT in $(git remote); do git pull -v $RMT $1; done; }    
alias git-pullall=git-pullall

git-pushall () { for RMT in $(git remote); do git push -v $RMT $1; done; }
alias git-pushall=git-pushall

用法:

git-pullall master

git-pushall master ## or
git-pushall

如果您没有为git pulll提供任何分支参数,那么来自非默认远程的pull将失败;保持这种行为不变,因为它类似于git。