如何为 Git 设置两个远程源?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44714/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:03:19  来源:igfitidea点击:

How to have two remote origins for Git?

git

提问by Ravi Chhabra

My company is a small one where we would be using Git for version control. The main server will be local. But we do want an server where our local repo is kept online to give access to our clients so that they can have assurance that we are doing the right thing and to allow them to check out from there if needed.

我的公司很小,我们将使用 Git 进行版本控制。主服务器将是本地的。但我们确实想要一个服务器,我们的本地存储库保持在线状态,以便我们的客户可以访问我们的客户,以便他们可以保证我们正在做正确的事情,并允许他们在需要时从那里查看。

So if I simply wish to push only to the one outside, and will never pull from it, what is the best Git way to do this?

因此,如果我只是希望只推到外面的那个,并且永远不会从中拉出来,那么最好的 Git 方法是什么?

回答by Grégtheitroade Cachet

You can add remotes with git remote add <name> <url>

您可以添加遥控器 git remote add <name> <url>

You can then push to a remote with git push <name> master:masterto push your local master branch to the remote master branch.

然后,您可以推送到远程git push <name> master:master以将本地主分支推送到远程主分支。

When you create a repo with git clonethe remote is named originbut you can create a publicrepository for your online server and push to it with git push public master:master

当您使用git clone远程命名origin创建public存储库时,但您可以为您的在线服务器创建一个存储库并使用git push public master:master