Help, my Repository is out of date

Help, my Repository is out of date

·

3 min read

If you're like me, you've probably seen a project that you like and forked it only to forget about it months later.

Suddenly, you're going through your repositories and stumble on it again. You then go down the rabbit hole of checking the original link.

To your utter horror, they moved on and left you behind. In the blink of an eye, you're carrying old news. The repository has forgotten all about you. Okay, a bit dramatic, but you get the point.

What do you do next? The first thing I did was to click through Github trying to figure out a way to get your forked project up to date. Next, you probably hit Google (or in my case, DuckDuckGo).

You find mentions of what could be done to 'fix' things, but nothing that says "start here" and "end here". Just one or two-liners saying 'just clone it again and then push it your repo'.

By the time you make sense of what they are talking about, given that we are new to Github, we lose interest and move on.

Weeks and months later, you come across another project that has suffered the same fate, so you repeat the cycle.

Today I experienced this again and said enough is enough. Below, I am going to show you the steps I take to resolve this and you can bookmark this article so you can always refer back to it. Let's break it down.

The Problem This branch is 2 commits behind fakename:master.

image1.PNG

The Solution

  • You will need git installed and set up on your system. A good place to start is the Git website
  • Launch a terminal (Mac) or Command Prompt (Windows) or Git Bash (Windows).
  • Navigate to the folder containing the project (or create a new folder and cd to it). E.G.

cd /C/Users/username/Documents/GitHub

  • Clone your forked project (the one from your account) if it's not already on your system using (origin):

git clone https://github.com/Your-Username/Forked-Repo.git

You should see something like:

image3.PNG

  • Change directory to the cloned project folder cd python-facebook image4.PNG
  • Next, add a reference to the original project (upstream) using:

git remote add upstream https://github.com/Original-Owner/Original-Repo].git

  • Then confirm you can see both repositories, yours (origin) and original (upstream) using: git remote -v

image5.PNG

  • Now, we get the new changes from the upstream with git fetch upstream That should give you an output similar to:

image6.PNG

  • Before we merge any changes, let's make sure we're on our (fork) master/main branch: git checkout master

image7.PNG

  • Now we can merge changes from upstream/master (original author) to local (fork) using: git merge upstream/master Expected output:

image8.PNG

  • Finally, we push those changes to GitHub: git push origin master

The final result should be something like:

image9.PNG