You decided to fork a project on Github, committed some changes and then… the original project was updated. Now you want to merge the changes made to the original project into your fork, and you don’t know how to do it. Today I’m explaining how to update your forks the easy way.
- Clone your fork to your working machine:
git clone firstname.lastname@example.org:YOUR-USERNAME/YOUR-FORKED-REPO.git
- Add the original project’s repository to your fork as a remote:
cd into/cloned/fork-repo git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git git fetch upstream
- Pull everything:
git checkout master git pull upstream master
- Merge the original project (upstream) into your fork (master) and push it:
git merge upstream/master git push
Congrats, your fork is now up to date! Easy isn’t it?