This tutorial is intended for git beginners who need to sync up their working repo with changes made to the upstream repo. Cloning repos within collaboration platforms such as gitlab will not be part of this tutorial.
For the purposes of this project, we will use https://github.com/w3c-social/activipy as the upstream repository. Create a clone of the project, and then clone your github repo to your dev environment.
At this point, the “origin” remote should be your working github repo of “activipy”. We need to add a “root” repo that upstreams to https://github.com/w3c-social/activipy.git since we want to make sure that we merge any merge/pull requests created by others before we submit our own merge/pull request.
Run the following to set up the “root” remote:
git remote add root https://github.com/w3c-social/activipy.git
git fetch root
For the sake of illustration, let’s pretend that while we were coding our contributions there pull requests accepted and added to the “root” repo. We need to merge those changes with ours before we submit our merge request. To do that, run the following:
git merge remotes/root/master
In the best case, our changes are simply fast-forwarded and everyone is happy. The more likely scenario is we end up with a “merge” commit. The worst case is we have conflicting changes. In that case, resolve all conflicts and follow directions printed on the screen to complete the merge.
At this point, git push your master branch to “origin/master” and you’re ready to submit a merge/pull request.