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 git@github.com:victoryoalli/framework.git (fetch)
origin git@github.com:victoryoalli/framework.git (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 `https://github.com/laravel/framework.git``
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 https://github.com/laravel/framework.git
And now if we execute git remote -v
we will see something similar to the following:
origin git@github.com:victoryoalli/framework.git (fetch)
origin git@github.com:victoryoalli/framework.git (push)
upstream https://github.com/laravel/framework.git (fetch)
upstream https://github.com/laravel/framework.git (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! :)