从另一个仓库Git拉 [英] Git pull from another repository
问题描述
我有一个名为 Generic
的存储库,它是一个通用应用程序。我将它分成了一个名为 Acme
的存储库,它只是建立在存储 Generic
存储库的应用程序上,并添加了Acme Co品牌如果我对 Generic
中的核心功能进行了更改,我想更新 Acme
存储库,其中包含我对 Generic
中的核心功能所做的最新更改。我会怎么做?
据我所知,我本质上是试图将上游存储库中所做的更改合并到当前的分支中。
如果这意味着什么,我正在尝试这样做,因为我有一个通用应用程序,然后构建并为各个客户端创建品牌(如 Acme
在这个例子中)。如果有更简单的方法,请告诉我。
在 Acme
回购。它添加了一个名为上游
的新远程仓库,该仓库指向通用
回购。
git remote add upstream https://location/of/generic.git
然后,您可以将对 Generic
所做的任何更改合并到 Acme
中的当前分支中,使用以下命令:
git pull upstream
如果您只是希望它在不自动合并的情况下下载更改,请使用 git fetch
而不是 git pull
。
如果您想禁用推送到该存储库,请使用
$ b等设置推送网址为无效网址$ b
git config remote.upstream.pushurl永远不会让你失望
如果您尝试推送至上游
(而且抱歉,Git将无法找到回购协议Rickroll,但它是第一个弹出的随机字符串进入我的脑海)。
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.
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.
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.
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
You can then merge any changes made to Generic
into the current branch in Acme
with the following command:
git pull upstream
If you just want it to download the changes without automatically merging, use git fetch
instead of git pull
.
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 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屋!