How to Sync Your Forked GitHub Repository with the Upstream Repo (Beginner Guide)


Recently, I forked an open-source repository on GitHub with the intention of contributing to the project. After forking, I had to step away from the fix I'd identified and returned to it several days later.
Upon resuming work, I noticed a message stating "This branch is 11 commits behind." If you've contributed to open-source projects before, you've likely encountered this situation.
In this guide, I'll explain what this message means and demonstrate how to properly sync your forked repository with the upstream repo to ensure you're working with the latest code.
What Does “11 Commit Behind” Mean?
When you fork a repository, you make a personal copy of it under your GitHub account. However, the original repository (called the upstream repo) keeps moving forward as other people contribute. When your fork doesn’t have the latest changes, GitHub shows that it’s “X commits behind”.
Keeping your fork updated is important before submitting pull requests so that your work is based on the latest version of the codebase.
How to Sync Your Fork Using Git (Command Line)
Here’s how to do it step-by-step:
1. Add the upstream remote
Open your terminal and navigate to your local clone of the forked repo.
git remote add upstream https://github.com/ORIGINAL_OWNER/REPO_NAME.git
This tells Git where the original project lives.
You can verify the remotes:
git remote -v
2. Fetch the upstream changes
git fetch upstream
This downloads the latest changes from the upstream repo, but doesn’t merge them yet.
3. Merge upstream into your local branch
If your default branch is main
:
git checkout main
git merge upstream/main
If it’s master
, just replace main
with master
.
4. Push the updated branch to your fork on GitHub
git push origin main
Now your GitHub fork is fully synced!
Prefer the GitHub Web Interface?
If you're not comfortable with the command line yet, GitHub has a handy “Sync fork” button.
Go to your forked repository on GitHub.
Look for a message like “This branch is X commits behind...”
Click Sync fork → Update branch.
Done!
A Few Tips for Beginners
Always sync your fork before starting new work or opening a pull request.
Use a separate branch for each new feature or bugfix.
Don’t be afraid to ask questions; open-source communities are often very welcoming!
🎉 You’re Ready to Contribute!
Keeping your fork in sync is a key part of the open-source workflow. Now that you’ve got this down, you're one step closer to becoming a confident open-source contributor.
Got stuck? Drop a comment or reach out to the project maintainers; they'll usually be happy to help!
Happy coding, and welcome to open source! 💻🌍
Subscribe to my newsletter
Read articles from JayRam Nai directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

JayRam Nai
JayRam Nai
Open edX expert and open-source enthusiast.