Skip to content

Instantly share code, notes, and snippets.

@bratucornel
Created August 20, 2021 06:09
Show Gist options
  • Save bratucornel/eabb809af7cb3a1f21120cdd81f13327 to your computer and use it in GitHub Desktop.
Save bratucornel/eabb809af7cb3a1f21120cdd81f13327 to your computer and use it in GitHub Desktop.
How to update a forked repo with git rebase

Git Rebase on top of forked repo

  1. Add the remote (original repo that you forked) and call it upstream
git remote add upstream https://github.com/original-repo/name.git
  1. Fetch all branches of remote upstream
git fetch upstream
  1. Rewrite your main branch with upstream’s main using git rebase.
git rebase upstream/main
  1. Push your updates to main. You may need to force the push with --force.
git push origin main --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment