Software construction, the web, and other techs

How to catch up my git fork to master

TL;DR

git fetch upstream
git checkout master
git merge upstream/master

Here I am in one of my forked gitrepositories on GitHub. I have a patch to contribute, a bug to fix but I want to make sure that my local copy of the repository is not stale. If I do not, the project I want to contribute might not be able to apply my patch or merge my pull request cleanly. The first thing I need to do is to catch up my git form to whatever the current code is in the master branch. Some development workflows will use a different branch than master for day-to-day development but the same steps apply using whatever that branch name is. In this post, I’ll assume you are using master. You’ll need a git command line tool.

There are two steps required. First, you must configure a git remote for a fork. Then you can catch up that fork to the current master.

Open a command line prompt and change the current directory to your project.

Configuring a git remote for a fork

You only need to do this once: Add a new remote upstream repository to sync with the fork where ORIGINAL_OWNER is the original GitHub account and ORIGINAL_REPOSITORY is the original repository name.