Git 从另一个仓库拉取 [英] Git pull from another repository

查看:44
本文介绍了Git 从另一个仓库拉取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 Generic 的存储库,它是一个通用应用程序.我已将其分叉到一个名为 Acme 的存储库中,该存储库仅构建在应用程序存储的 Generic 存储库上,并为其添加了 Acme Co 品牌.

I have a repository called Generic, which is a generic application. I have forked it into a repository called Acme, which just builds upon the application stored Generic repository and adds Acme Co branding to it.

如果我对 Generic 中的核心功能进行更改,我想使用我对 中的核心功能所做的最新更改来更新 Acme 存储库通用.我该怎么做?

If I make changes to the core functionality in Generic, I want to update the Acme repository with the latest changes I have made to the core functionality in Generic. How would I do that?

据我所知,我实际上是在尝试将上游存储库中所做的更改合并到当前分支中.

As far as I can tell, I am essentially trying to merge the changes made in an upstream repository into the current fork.

如果这意味着什么,我正在尝试这样做,因为我有一个通用应用程序,然后我可以在此基础上为各个客户构建和品牌化(例如本示例中的 Acme).如果有更简洁的方法,请告诉我.

If it means anything, I'm trying to do this because I have a generic application that I then build upon and brand for individual clients (like Acme in this example). If there is a cleaner way of doing this, let me know.

推荐答案

在您的 Acme 存储库中发出以下命令.它添加了一个名为 upstream 的新远程存储库,指向 Generic 存储库.

Issue the following command in your Acme repo. It adds a new remote repository named upstream that points to the Generic repo.

git remote add upstream https://location/of/generic.git

然后,您可以使用以下命令将对 Generic 所做的任何更改合并到 Acme 中的当前分支中:

You can then merge any changes made to Generic into the current branch in Acme with the following command:

git pull upstream

如果您只想下载更改而不自动合并,请使用 git fetch 而不是 git pull.

If you just want it to download the changes without automatically merging, use git fetch instead of git pull.

如果您想禁用推送到该存储库,请使用类似的内容将推送 URL 设置为无效 URL

If you want to disable pushing to that repository, set the push URL to an invalid URL using something like

git config remote.upstream.pushurl "NEVER GONNA GIVE YOU UP"

如果您尝试推送到上游,Git 现在会向您大吼大叫,因为无法找到存储库(并且对 Rickroll 感到抱歉,但这是第一个出现在我脑海中的随机字符串).

Git will now yell at you about not being able to find a repo if you try to push to upstream (and sorry about the Rickroll, but it was the first random string that popped into my head).

这篇关于Git 从另一个仓库拉取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆