git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
git pull upstream master
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
git pull upstream master
Thank you.
Thanks. This Helps me a lot. 🙂
These comments all seem to depend on cloning the repo to your local computer and doing the fetch and merge there followed by a push. You can perform the sync to the upstream repo directly on github. Generate a pull request at the upstream repo (there is a link "compare forks") specifying your fork as the base and the upstream branch you want to merge as the head. Generate the pull request and if all goes well, you can accept your PR and you do not have to fetch both to your local site. The merge is done directly on github.
Thanks. Saved my day.
Thanks, helped a lot.
I built a web based solution to sync the fork with the original using only GitHub APIs. It's all web, you don't need to do anything on the client
https://forkrefresh.herokuapp.com
As a plus it tells you the status off all your repos as compared to sources of the forks.
This helps! Thank you
Thank you ❤️
git pull is a git fetch and git merge in one step.
So the git fetch in step 2 is redundant if you're going to do a git pull anyway.
I second this. git fetch and then git pull won't break anything, but it's redundant.
You can update it to:
git pull upstream main
This post should have been the first Google result. Would have saved me some time.
You can update it to:
git pull upstream main
thank you @maryamrmz it worked for me!
How to keep a full project in sync, all the branches from the server and automated (no local checkout)?
I just want a slave mirror.
Found an automatic and flexible solution using Github Actions that can be easily applied quickly to any fork.
See my blog post: https://blog.mathieu.photography/post/649318432483033088/automatic-fork-syncing-with-github
Or Gist: https://gist.github.com/mathieucarbou/96ab30024f0d3fb44cac970219d23efc
Hi everyone.
I tried the commands suggested in this post. I was able to add the remote but when I try to pull for updating local I get the error "The unauthenticated git protocol on port 9418 is no longer supported.". I solved it using http// instead of git// when adding the upstream.
I find it funny that years after years I keep coming back to this gist.
I find it funny that years after years I keep coming back to this gist.
Based on this awesome gist, I made a little bash function for myself and use it on a few machines so I don't have to remember 😅
Just FYI, here's a method for anyone who wants to sync their GitHub forks with upstream without having to create a local clone:
The official GitHub CLI now supports syncing forks remotely with this simple command... (From GitHub's official docs:) "To update the remote fork from its parent, use the gh repo sync -b BRANCH-NAME
subcommand and supply your fork and branch name as arguments.
gh repo sync owner/cli-fork -b BRANCH-NAME
If the changes from the upstream repository cause conflict then the GitHub CLI can't sync. You can set the --force
flag to overwrite the destination branch."
Note
It is also possible to simplify the command by only supplying your fork (in the username/repo name syntax), like so:
gh repo sync OWNER/REPO
GitHub CLI will attempt to match your default/main/master branch with that of the parent and sync the two -- assuming there are no merge conflicts. Otherwise, it will notify of such.
fatal: Couldn't find remote ref master
after running
git pull upstream master