DEV Community

0 seconds of 0 secondsVolume 90%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:00
00:00
 
Michelle Duke
Michelle Duke

Posted on • Edited on

5

Using the GitHub CLI to update your repo

Have you ever forked a repo, only to come back to it months later and realise your fork is totally out of date?

This is what happened to me this week whilst live coding. We were working through the Flame of Open Source on Twilio Quest. It had been a while since I'd completed this mission. We were going over the quest, talking about open source, how to get involved, and how to find good projects.

twilio-quest-oss-banner.width-800

The Flame of Open source uses an open source repo to show you how to contribute to open source. Since I'd already done this mission, I had the repo forked on my GitHub account, and as a local git repository. But the fork was now 759 commits behind the main branch. One way around this would be to delete the repo and re-clone it.

But there's a better way - updating the repo to match the main branch. You can use the command line with GitHub to do this.

First, navigate to your local git repository:

cd [file path]

Now we need to grab the path to the main branch you originally forked it from:

git remote add upstream [URL ending in *.git]

Then pull this into your local repository:

git remote pull upstream main

During the above step, make sure you're on the right branch. If you're not on the correct branch, use git checkout [branch name] to switch to the correct branch (this is what I did wrong originally) 🤦

Now everything is up to date locally. All you need to do is push all the changes back to GitHub:

git push

Everything now looks good. One of the great things about live streaming is you can learn on the go from people around you. If you want to check out this 🍵 Twilio Quest and Tea 🍵 stream, you can watch the recording on Twitch. Or come and join us sometime at MishManners.

Twitter cardSmall

Runner H image

Check out the Runner H "AI Agent Prompting" Challenge Winners! 👀

From culinary assistants to sports analysis tools to hackathon discovery agents, our submissions were full of diverse use cases!

Read more →

Top comments (0)

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server 🏁

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

👋 Kindness is contagious

Explore this practical breakdown on DEV’s open platform, where developers from every background come together to push boundaries. No matter your experience, your viewpoint enriches the conversation.

Dropping a simple “thank you” or question in the comments goes a long way in supporting authors—your feedback helps ideas evolve.

At DEV, shared discovery drives progress and builds lasting bonds. If this post resonated, a quick nod of appreciation can make all the difference.

Okay