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
353 views
in Technique[技术] by (71.8m points)

fork - Updating forked GitHub repo to match original's latest code and commits

I forked a GitHub project several days ago and from its issues, I can see that the master branch has had some modifications since.

When I cd to my location directory of this project and use git pull, it says, "Already up-to-date". Why?

How do I update my fork to include the commits from the original repo?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

When you fork a repository, a copy of the original repository is established on your GitHub account. This permits read+write access to the "copy".

When the original repository resource has commits that would benefit your copy, follow these steps to update your fork's master branch. You could update other branches, but typical workflow is to update master against the original repository.

  1. Open a Terminal
  2. cd to your project directory
  3. git remote add upstream <url-of-original-repository>
  4. git branch and verify you are on master branch
  5. git pull --rebase upstream master

Step #5 will fetch all new commits of the "original" repository, apply them to master branch from the last merge-base, then include all of your branch's commits "on top".

Any time you need to update your fork again, simply run the command in step #5.


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

1.4m articles

1.4m replys

5 comments

57.0k users

...