I wanted to commit somthing to a github repository, but I (obviously) didn\'t have any rights to do so. I made a fork of that repo, commited my changes and submitted a pull-
To sync changes you make in a fork with the original repository, you must configure a remote that points to the upstream repository in Git.
Specify a new remote upstream repository that will be synced with the fork.
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
You can check if it was succesful with:
git remote -v
Then fetch it to update your project:
git fetch upstream
Merge the changes from upstream/master into your local master branch.
git merge upstream/master
At last, you can commit new update from original repository to your fork repository.
This information can also be found on GitHub here and here.
Adding to Diki Andriansyah
answer, rather than using
git merge upstream/master
try using:
git pull upstream master
This helped me :) .
I had the same problem and made a docker
container that will update the forked branch I care about.
Try using fork-sync
The README walks you through how to configure a docker image that will clone, setup a remote to track upstream, fast forward the desired branch, and finally push the changes to your fork. The same container can be started over and over again to keep the branch up to date. I set my docker container to run on a crontab
so that every two hours my workstation is updating the forks I regularly contribute to.
I wanted to be able to make branches which tracked my fork from the tip of upstream. This could have been accomplished with git checkout -b mybranch upstream/master
. But this by default sets upstream
as the remote, which means if I push
my branch will go to the upstream
repo, and possible trigger CI jobs. Now, I can do a git checkout -b mybranch origin/master
and not have to worry about a dangerous push waiting for me later.