I forked someone\'s repository on GitHub and would like to update my version with commits and updates made in the original repository. These were made after I forked my copy
You have to add the original repository (the one you forked) as a remote.
From the GitHub fork man page:
Once the clone is complete your repo will have a remote named “
origin
” that points to your fork on GitHub.
Don’t let the name confuse you, this does not point to the original repo you forked from. To help you keep track of that repo we will add another remote named “upstream”:
$ cd github-services
$ git remote add upstream git://github.com/pjhyett/github-services.git
$ git fetch upstream
# then: (like "git pull" which is fetch + merge)
$ git merge upstream/master master
# or, better, replay your local work on top of the fetched branch
# like a "git pull --rebase"
$ git rebase upstream/master
You have also a ruby gem which can facilitate those GitHub operations.
See also "Git fork is git clone?".
If there is nothing to lose you could also just delete your fork just go to settings... go to danger zone section below and click delete repository. It will ask you to input the repository name and your password after. After that you just fork the original again.
To automatically sync your forked repository with the parent repository, you could use the Pull App on GitHub.
Refer to the Readme for more details.
For advanced setup where you want to preserve your changes done to the forked repository, refer to my answer on a similar question here.
Use:
git remote add upstream ORIGINAL_REPOSITORY_URL
This will set your upstream to the repository you forked from. Then do this:
git fetch upstream
This will fetch all the branches including master from the original repository.
Merge this data in your local master branch:
git merge upstream/master
Push the changes to your forked repository i.e. to origin:
git push origin master
Voila! You are done with the syncing the original repository.
This video shows how to update a fork directly from GitHub
Steps:
Pull Requests
.New Pull Request
. By default, GitHub will compare the original with your fork, and there shouldn’t be anything to compare if you didn’t make any changes.switching the base
. Now GitHub will compare your fork with the original, and you should see all the latest changes.Create a pull request
for this comparison and assign a predictable name to your pull request (e.g., Update from original).Create pull request
.Merge pull request
and finally Confirm
merge. If your fork didn’t have any changes, you will be able to merge it automatically.If you want to do it without cli, you can do it fully on Github website.
New pull request
.Create new pull request
.