Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

version control - Git pull from another repository

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...