添加两个repos到git config,如何在推送后自动获取两个?

时间:2016-11-10 20:13:31

标签: git

推送后branch -av中获取所有分支(通过[remote "all"]之间的origin检查一致性)的好方法是什么?我对backup[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [remote "origin"] url = git@host:origin/repo.git fetch = +refs/heads/*:refs/remotes/origin/* [remote "backup"] url = git@host:backup/repo.git fetch = +refs/heads/*:refs/remotes/backup/* [remote "all"] url = git@host:origin/repo.git url = git@host:backup/repo.git fetch = +refs/heads/*:refs/remotes/origin/* fetch = +refs/heads/*:refs/remotes/backup/* [branch "master"] remote = all merge = refs/heads/master 都进行了抓取,但它只获取第一个。

git push all [branch]

我目前正在键入git fetch all,然后是[remote "all"],因为它自动抓取的唯一提取是TXMLDocument中列出的第一个回购(即使我已列出。)

1 个答案:

答案 0 :(得分:2)

您无法为fetch执行此操作。 (您可以push,但我仍然反对。如果您想保留all,我至少建议您将url设置为无效并设置通过pushurl推送网址 - 虽然我承认我从未测试过此设置。)

您可以而且应该做的是声明多个遥控器(就像您所做的那样,远程origin和远程backup)然后声明远程组< / em>如the git remote documentation中所述。默认组名为default,如果您没有定义一个,git remote update默认自动查找所有遥控器,仅跳过配置了特殊&#34; I的那些我不在默认设置中#34;标志。

因此,只需删除all回购,而不是运行git fetch,运行git remote update(或git fetch --all)。 (或者让all留在那里进行推动,但我的强迫症仍然说'不要那样做&#34; :-))