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 own fork and you don’t 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 email@example.com: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 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?