git 是否可以从一个 repo 中提取并推送到另一个 repo?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4523496/
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
Is it possible to pull from one repo and push to other one?
提问by chopi321
I have one repo in github which is public, there I have an Open source application i'm working on that is for making product catalogs, and small cms content.
我在 github 中有一个公开的 repo,在那里我有一个我正在开发的开源应用程序,用于制作产品目录和小的 cms 内容。
I also have a private repository (not hosted in github) which is an application developed under the open source application hosted in github.
我还有一个私有存储库(不在 github 中托管),它是在 github 中托管的开源应用程序下开发的应用程序。
Since I'm currently working on both applications, adding features in the open source one and also making changes in the private one like changing the template and also pulling the code from the open source one.
由于我目前正在开发这两种应用程序,因此在开源应用程序中添加功能并在私有应用程序中进行更改,例如更改模板以及从开源应用程序中提取代码。
I was wondering if there is any way in which I could pull the new stuff from the open source one but also pushing the code of the new application to the other repo.
我想知道是否有任何方法可以从开源程序中提取新内容,同时将新应用程序的代码推送到另一个存储库。
采纳答案by Reactormonk
git pull private master
and git push github master
pulls from your private repo (given it's named like that) and pushes to github (might also be called origin
). It's not SVN ;-)
git pull private master
并git push github master
从您的私人仓库中提取(假设它是这样命名的)并推送到 github(也可能称为origin
)。这不是 SVN ;-)
回答by Aristotle Pagaltzis
Set a push URL for the remote that is different from the pull URL:
为远程设置一个不同于拉取 URL 的推送 URL:
git remote set-url --push origin [email protected]:repo.git
This changes the remote.name.pushurl
configuration setting. Then git pull
will pull from the original clone URL but git push
will push to the other.
这会更改配置设置。然后将从原始克隆 URL 中拉取,但会推送到另一个。remote.name.pushurl
git pull
git push
In old Git versions, git remote set-url
did not have the --push
switch. Without it, you have to do this by changing the configuration setting manually:
在旧的 Git 版本中,git remote set-url
没有这个--push
开关。没有它,您必须通过手动更改配置设置来执行此操作:
git config remote.origin.pushurl [email protected]:repo.git