How do I update a GitHub forked repository?

This can work for another provider different to GitHub but for this exercise I´m going to focus on GitHub.

Remote Repositories

We can look at which repositories we are pointing to.

git remote -v

For example:

origin (fetch)
origin (push)

As you can see I only have the ones pointing to my repository so I´m going to add another one pointing to the original repository in my case is ```

We need to have our own origin fetch and push url repositories and the original repository to fetch from there.

I´m going to add the original one to the upstream

git remote add upstream

And now if we execute git remote -v we will see something similar to the following:

origin (fetch)
origin (push)
upstream (fetch)
upstream (push)

We update the original repository

git fetch upstream

Now you can move back to your origin master or the branch that you want to have updated. In my case is master and I will use --track to have master as my default.

git checkout --track origin/master

Now that I´m on my own master branch I can merge with the original branch of my desire.

git merge upstream/master

And That´s it! :)

Victor Yoalli

This is me.