This one is entirely for me. I know this is pretty basic stuff, but I don’t do this often enough to remember the steps and finally got sick of looking it up each time.
Here’s the scenario this covers: In my Github account, I have a forked copy (I’ll call this origin) of a repo owned by someone else (I’ll call this upstream). I also have a local copy on my development machine (I’ll call this local). The owner of upstream is continuing to make changes, and I am making changes to local and pushing them to origin. Periodically, I need to pull copies made to upstream into my development efforts (local and origin) to make sure I’m not going to have problems merging my changes into upstream when I’m ready.
Here are the steps:
- [Only the first time you go through this process]: From a git bash prompt in your local git repo folder, add a git remote pointing to upstream: git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
- Fetch upstream to local: git fetch upstream
- Make sure you have local/master checked out: git checkout master.
- Merge upstream/master with local/master: git merge upstream/master. If you have local changes to files that are part of the merge, you’ll need to commit or stash them first.
- You now have an updated copy of upstream merged with local. All you need to do is push it to origin: git push origin master