This is a reminder post! I keep forgetting the steps I take to update a forked repo in GitHub with the latest version from the source repo (using the command line), so here’s what I do for anyone else that needs to do the same.
The assumption are that:
- You have a forked repo which is behind another repo’s updates, in GitHub.
- Locally, you have no copy of your forked repo (but that isn’t essential - just adapt the steps).
I’ll use a repo I recently worked with for the excellent blog by Brent Roose.
$ git clone https://github.com/s-moon/stitcher.io.git
Change the repo above to be your repo.
$ git remote add remote https://github.com/brendt/stitcher.io.git
Here, the source repo is Brent’s - it’s the one I originally forked. I’m also creating a remote named “remote” - the second usage of
$ git pull remote
These are Brent’s changes that he has added since to his original repo.
If you like, you can see the changes that were retrieved with this command:
$ git branch -va
$ git checkout master
$ git merge remote/master
Here, we’re merging in the new changes that we don’t have.
$ git push
Lastly, push all these changes to your forked repo.
Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’ logicalmoon.com