是否可以从一个存储库中拉取并推送到另一个存储库?

发布于 2024-10-09 00:25:37 字数 262 浏览 4 评论 0 原文

我在 github 上有一个公开的存储库,在那里我有一个正在开发的开源应用程序,用于制作产品目录和小型 cms 内容。

我还有一个私有存储库(未托管在 github 中),它是在 github 中托管的开源应用程序下开发的应用程序。

由于我目前正在开发这两个应用程序,因此在开源应用程序中添加了功能,并在私有应用程序中进行了更改,例如更改模板以及从开源应用程序中提取代码。

我想知道是否有任何方法可以从开源中提取新内容,同时将新应用程序的代码推送到另一个存储库。

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.

I also have a private repository (not hosted in github) which is an application developed under the open source application hosted in 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尐偏执 2024-10-16 00:25:37

设置与拉取 URL 不同的远程推送 URL:

git remote set-url --push origin [email protected]:repo.git

这会更改 remote.name.pushurl 配置设置。然后 git pull 将从原始克隆 URL 拉取,但 git Push 将从原始克隆 URL 推送到另一个。


在旧的 Git 版本中,git remote set-url 没有 --push 开关。如果没有它,您必须通过手动更改配置设置来完成此操作:

git config remote.origin.pushurl [email protected]:repo.git

Set a push URL for the remote that is different from the pull 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.


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 config remote.origin.pushurl [email protected]:repo.git
独留℉清风醉 2024-10-16 00:25:37

git pull private mastergit push github master 从您的私有存储库中拉取(假设它是这样命名的)并推送到 github(也可能称为 origin)。这不是 SVN ;-)

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 ;-)

歌入人心 2024-10-16 00:25:37

当然!
只需进入 .git 文件夹并打开配置文件,然后对其进行编辑,如下所示:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[submodule]
    active = .
[remote "remoteA"]
    url = https://github.com/userA/repoX.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[remote "remoteB"]
    url = https://github.com/userB/repoX.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[pull]
    ff = only
    rebase = true

之后,您可以根据需要运行以下命令:

> git pull remoteA [branch_nameX]
> git push remoteB [branch_nameY]

of course!
Just get in .git folder and open config file, then edit it, as bellow:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[submodule]
    active = .
[remote "remoteA"]
    url = https://github.com/userA/repoX.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[remote "remoteB"]
    url = https://github.com/userB/repoX.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[pull]
    ff = only
    rebase = true

after this, you can run the following commands as you wish:

> git pull remoteA [branch_nameX]
> git push remoteB [branch_nameY]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文