I have been forking a few repos recently and noticing that get the latest updates from upstream repos has been failing. I have fixed every repo in much the same way but it always requires about 15 minutes of Googling to get there so hear are the steps to aid my memory.
In the following example I have forked the OpneLiveWriter repo and my user GitHub user name is
Initial Check
So we run the following remote –v command to see what the upstream url is set to, and the results in this case, show that we actually do not have an upstream repository defined.
git remote -v
> origin https://github.com/poppastring/OpenLiveWriter.git (fetch)
> origin https://github.com/poppastring/OpenLiveWriter.git (push)
Add an upstream repository
So this command adds an upstream repository:
> git remote add upstream https://github.com/OpenLiveWriter/OpenLiveWriter.git
Update the upstream repository
If, for whatever reason, the upstream repository is incorrectly defined you get reset the url with the following command:
> git remote set-url upstream https://github.com/OpenLiveWriter/OpenLiveWriter.git
Now if you review you remote settings you will see a newly defined set of upstream repositories for fetch and push.
git remote -v
> origin https://github.com/poppastring/OpenLiveWriter.git (fetch)
> origin https://github.com/poppastring/OpenLiveWriter.git (push)
> upstream https://github.com/OpenLiveWriter/OpenLiveWriter.git (fetch)
> upstream https://github.com/OpenLiveWriter/OpenLiveWriter.git (push)
Now you can get the latest updates from your upstream rep using this command:
git merge upstream/master
Comments are closed.