How to Keep Your Forked GitHub Repository up to Date?

It is quite normal that, once you fork a repository that you want to contribute to on GitHub, after some time your fork will get quite behind the original repository.

Here are the steps that you need to follow in order to get the newest changes from the original repository pulled into your fork!

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 1, 2020
Accepted Answer

As an example, I will use my fork of the LaraSail project.

As of the time being, it is 9 commits behind. In order to get started, you need to do is to clone your fork. You can do that by going to GitHub and clicking on the Clone button:

How to sync fork repository GitHub

Once you’ve copied the URL, go to your command line and run the following command:

  1. git clone

Note: Make sure to change the link so that it matches your forked repository

Once you’ve cloned the repository, cd into the directory:

  1. cd larasail

Then add the original repository to your fork as an upstream:

  1. git remote add upstream

Note: change the details to match the original repository

After that, fetch the latest changes from the original repository:

  1. git fetch upstream

The next thing that you need to do is to pull the latest changes in order to get your fork up to date:

  1. git pull upstream main

This could be considered as an optional step, but the last thing that you need to do is to push those changes to your fork on GitHub:

  1. git push origin main

Note: make sure to change main with the name of the branch that you want to sync with.

After that, if you go to your fork in GitHub, you will see a message saying This branch is even with the_origin_repo_name:main.

I hope that this helps! Regards, Bobby

Site Moderator
Site Moderator badge
February 4, 2021

Hello, all

What you can also do is to create a little bash script to pull the changes with one command instead of running them one by one.

If you want to add an alias instead of using a bash script just open your .bashrc (or .zshrc, depending on your shell) and set an alias

alias sync-repository="git fetch upstream && git checkout main && git merge upstream/main"

after that you will need to source the ~/.bashrc or the ~/.zshrc file with this command:

source ~/.bashrc

source ~/.zshrc

now you can use the alias when you’re in the project directory and just execute the name of the alias:


Another really useful solution is to use a Github Probot App called Pull

The app will automatically watch and pull in upstream’s default (master) branch to yours using hard reset every few hours. You can check it here:

Additional features are:

  • Ensure forks are updated.
  • Automatically integrate new changes from upstream.
  • Pull requests are created when upstreams are updated.
  • Automatically merge or hard reset pull requests to match upstream.
  • Add assignees and reviewers to pull requests.
  • Customize pull request label.
  • Honor branch protection rules.
  • Work well with pull request checks and reviews.

Regards, Alex

Hi For keeping a forked repository up to date: you just need to go to the location of the repository in your local disk and then run the command:

$ git pull <URL of the repo you forked>

It will not only bring changes to your local disk but also merge it inside it. I hope it helps.

Regards Neha Singh

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel