George Profenza
George Profenza

Reputation: 51837

How to sync with a remote Git repository?

I forked a project on github, made some changes, so far so good.

In the meantime, the repository I forked from changed and I would like to get those changes into my repository. How do I do that ?

Upvotes: 113

Views: 375774

Answers (5)

Kelvin Maina
Kelvin Maina

Reputation: 11

On github UI, switch to the branch you want to update with new changes from fork. Then simply select:

fetch upstream

Upvotes: 1

Alex
Alex

Reputation: 34958

You have to add the original repo as an upstream.

It is all well described here: https://help.github.com/articles/fork-a-repo

git remote add upstream https://github.com/octocat/Spoon-Knife.git
git fetch upstream
git merge upstream/master
git push origin master

Upvotes: 50

Mark Hibberd
Mark Hibberd

Reputation: 2070

Assuming their updates are on master, and you are on the branch you want to merge the changes into.

git remote add origin https://github.com/<github-username>/<repo-name>.git
git pull origin master

Also note that you will then want to push the merge back to your copy of the repository:

git push origin master

Upvotes: 72

Abizern
Abizern

Reputation: 150565

You need to add the original repository (the one that you forked) as a remote.

git remote add github (clone url for the orignal repository)

Then you need to bring in the changes to your local repository

git fetch github

Now you will have all the branches of the original repository in your local one. For example, the master branch will be github/master. With these branches you can do what you will. Merge them into your branches etc

Upvotes: 5

Šimon T&#243;th
Šimon T&#243;th

Reputation: 36423

Generally git pull is enough, but I'm not sure what layout you have chosen (or has github chosen for you).

Upvotes: 97

Related Questions