简体   繁体   English

Git:git会推送到所有远程存储库吗?

[英]Git: does git push to all remote repositories?

I have a local git repository that I use in combination with a (private) remote git repo. 我有一个本地git存储库,可与(私有)远程git存储库结合使用。 The code I'm working on comes originally from an open-source project on github, so I added it as a remote to the github repository (with git remote add). 我正在处理的代码最初来自github上的开源项目,因此我将其添加为github存储库的远程文件(使用git remote add)。

I noticed (with git remote -v) that for both, fetch and push, the remote repository has been added. 我注意到(使用git remote -v),对于获取和推送,都添加了远程存储库。 According to another question here on SO, it's not possible to only have a fetch remote repo. 根据关于SO的另一个问题,不可能只获取远程回购。 However, I only want to fetch from github, not push. 但是,我只想从github获取,而不是push。

So, my question is: the moment I do a git push, does it push to all the remote repositories (including the one from github, in this case), or only to my first remote repository? 所以,我的问题是: 当我执行git push时,它会推送到所有远程存储库(在这种情况下,包括从github的存储库),还是仅推送到我的第一个远程存储库?

No, it does not. 不,不是的。 (And you could easily just have tried that) (您很容易尝试过)

git push MYREMOTE MYBRANCH

将为您提供所需的东西。

git push origin will push all changes on the local repositories that have matching remote repositories at origin As for git push git push origin将在本地存储库上推送与原始存储库中匹配的远程存储库匹配的所有更改。

Works like git push , where is the current repositories's remote (or origin, if no remote is configured for the current branch). 就像git push一样,这里是当前存储库的远程目录(如果没有为当前分支配置远程目录,则为源)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM