Doing this manually is no longer necessary , with modern versions of git
!
(对于现代版本的git
, 不再需要手动执行此操作 !)
See Malvineous 's solution, below. (请参阅下面的Malvineous解决方案。)
Reproduced here:
(转载于此:)
git remote set-url origin --push --add <a remote>
git remote set-url origin --push --add <another remote>
Original answer: (原始答案:)
This something I've been using for quite a while without bad consequences and suggested by Linus Torvalds on the git mailing list .
(我已经使用了相当长的时间了,但并没有造成严重的后果,由git邮件列表上的Linus Torvalds提出。)
araqnid ’s solution is the proper one for bringing code into your repository… but when you, like me, have multiple equivalent authoritative upstreams (I keep some of my more critical projects cloned to both a private upstream, GitHub, and Codaset), it can be a pain to push changes to each one, every day.
(araqnid的解决方案是将代码引入您的存储库的合适解决方案……但是当您像我一样拥有多个等效的权威上游时(我将一些更重要的项目克隆到了私有上游,GitHub和Codaset中),每天都要对每个更改进行更改可能会很痛苦。)
Long story short, git remote add
all of your remotes individually… and then git config -e
and add a merged‐remote.
(长话短说, git remote add
所有的远程…,??然后git config -e
并添加合并的远程。)
Assuming you have this repository config
: (假设您具有此存储库config
:)
[remote "GitHub"]
url = [email protected]:elliottcable/Paws.o.git
fetch = +refs/heads/*:refs/remotes/GitHub/*
[branch "Master"]
remote = GitHub
merge = refs/heads/Master
[remote "Codaset"]
url = [email protected]:elliottcable/paws-o.git
fetch = +refs/heads/*:refs/remotes/Codaset/*
[remote "Paws"]
url = [email protected]:Paws/Paws.o.git
fetch = +refs/heads/*:refs/remotes/Paws/*
… to create a merged‐remote for "Paws"
and "Codaset"
, I can add the following after all of those:
(…为"Paws"
和"Codaset"
创建合并的远程"Codaset"
,我可以在所有这些之后添加以下内容:)
[remote "Origin"]
url = [email protected]:Paws/Paws.o.git
url = [email protected]:elliottcable/paws-o.git
Once I've done this, when I git push Origin Master
, it will push to both Paws/Master
and Codaset/Master
sequentially, making life a little easier.
(完成此操作后,当我git push Origin Master
,它将依次推入Paws/Master
和Codaset/Master
,这使生活变得更轻松。)