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 ?

4 Answers

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

4

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

git remote add origin 
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
8

You have to add the original repo as an upstream.

It is all well described here:

git remote add upstream 
git fetch upstream
git merge upstream/master
git push origin master

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

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest