Update a Fork in Github
When I am contributing either to the core of WordPress or to another Github project, I like to create my own repository to avoid problems in the original.
The problem is that many times the original repository is updated before I finish my work, creating some conflicts in the pull request, as this does not exist in my fork, I always find myself looking for a way to update my fork with the work of the main repository.
This is the easiest way I have found:
Step 1: We add a new remote
with the original repository
(it can be called whatever we want, usually “upstream”)
1git remote add upstream https://github.com/usuario/repo-original.git2
STep 2: We fetch
the changes from the original repository
(not pull
, we don't want to merge
yet)
1git fetch upstream2
Step 3: We do a rebase
to replace the master of our repository,
with the original one
1git rebase upstream/master`}2
Step 4: We push
to have the updated master in our repo
1git push origin master2
Now we can merge
the new master into our branch to resolve conflicts.