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-request. Now, the problem is that after a while other people have made commits to the original repo, which means my fork is no longer up-to-date.
How should now update my fork? Is this (https://stackoverflow.com/a/23853061/5513628) still a valid way or do I have to delete my repo and make a new fork every time?
This is what the fork looks like in github desktop:
The pull request was made by me but the two commits after that were made by other people. They are not contained in my repo...
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.
Shortcut: you can also combine the last two commands into a single command:
git fetch upstream git merge upstream/master
Is equal to:
git pull upstream/master
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 :) .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With