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!
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!
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.
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:
Once you’ve copied the URL, go to your command line and run the following command:
Once you’ve cloned the repository,
cd
into the directory:Then add the original repository to your fork as an upstream:
After that, fetch the latest changes from the original repository:
The next thing that you need to do is to pull the latest changes in order to get your fork up to date:
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:
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
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:
sync-repository
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:
https://probot.github.io/apps/pull/
Additional features are:
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