October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Sync a GitHub Fork With Upstream Without Losing Work

Update your GitHub fork from upstream using the web interface, GitHub CLI, or local Git—with practical guidance for remotes, conflicts, merges, and pushes.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To sync a GitHub fork with its upstream repository, choose one of three routes: use GitHub’s web interface, run GitHub CLI, or fetch and merge with local Git. Before starting, confirm which repository is your fork and which is the original. The web and CLI methods update the hosted fork; local Git updates your checkout first, so you must push afterward if you also want the hosted fork updated.

Before syncing, check your fork and upstream

In a typical fork setup, origin refers to your fork and upstream refers to the original repository. Verify the remote names and URLs before changing a branch:

As an Amazon Associate I earn from qualifying purchases.

git remote -v

If upstream is missing, add the original repository as a remote, replacing the example owner and repository with the actual values, then check the list again:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPOSITORY.git
git remote -v

Protect any uncommitted changes before integrating upstream commits. Commit them, or otherwise save them somewhere safe. Also identify the branch you intend to update; examples below use main, but the upstream and fork may use a different default branch.

Which sync method should you use?

Method Where it updates Useful when Conflict behavior
GitHub web interface Hosted fork branch You want a quick update with a review of incoming commits GitHub may prompt you to create a pull request to resolve conflicts
GitHub CLI Hosted fork branch You prefer a concise command-line operation Sync stops if upstream changes cause conflicts; --force overwrites the destination branch
Local Git Local branch first; push to update hosted fork You want explicit control over fetching, branch selection, and integration A merge may require manual conflict resolution

Method 1: Sync through GitHub’s web interface

  1. Open your fork’s main page on GitHub.
  2. Select Sync fork.
  3. Review the incoming upstream commits.
  4. Select Update branch to apply them to the fork.

GitHub identifies write access to the fork as the relevant permission for this route. If the upstream changes conflict with the fork, GitHub may prompt you to create a pull request to resolve them. This method updates the hosted branch; it does not update a separate local checkout on your computer.

Method 2: Sync with GitHub CLI

Use gh repo sync with the fork’s owner, repository, and target branch:

gh repo sync OWNER/FORK -b BRANCH

For example, replace OWNER/FORK with the fork’s GitHub owner and repository name, and BRANCH with the branch to update. The command stops when upstream changes cause conflicts. GitHub documents --force as an option that overwrites the destination branch; it is not a routine conflict-resolution shortcut. Only consider it after checking that the destination work can safely be replaced.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Method 3: Fetch and merge with local Git

This route gives you control over the local branch and how upstream changes are integrated. GitHub’s example uses main; substitute the branch that your fork should track.

  1. Fetch upstream commits:
    git fetch upstream
  2. Switch to the branch in your local fork:
    git checkout main
  3. Merge the matching upstream branch:
    git merge upstream/main
  4. Push the updated branch to your fork, if you want the hosted fork updated too:
    git push origin main

Fetching downloads upstream changes without integrating them. The merge step brings the selected upstream branch into your local branch. If the local branch has no unique commits, Git may be able to fast-forward it. If it contains commits not in upstream, Git combines the histories; overlapping edits may require you to resolve conflicts.

Choose merge, fast-forward-only, or rebase

Merge: the straightforward default

git merge upstream/main is the clearest default when you want to preserve the existing local commit history. A merge keeps both lines of development; if Git cannot combine changes automatically, resolve the reported files, stage the resolutions, and complete the merge.

Fast-forward-only: stop rather than integrate divergent histories

If you expect your local branch to have no unique commits, git pull --ff-only is a conservative alternative. Git advances the branch only when that can be done as a fast-forward; if local and remote histories have diverged, the command fails instead of creating a merge commit or rebasing. Use it only when the relevant remote and branch are configured as expected.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Rebase: useful for private local commits, but rewrites history

Rebase reapplies your local commits on top of upstream and gives them new commit identities. It can be appropriate for commits that have not been published, but avoid casually rebasing work that others already rely on because rewriting published history can disrupt collaborators. Rebase is a local integration choice, not a separate GitHub web or CLI sync method.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

If a merge or rebase goes wrong

If you need to abandon an in-progress operation, Git provides a corresponding abort command:

  • For a merge, run git merge --abort.
  • For a rebase, run git rebase --abort.

These commands are for an operation that is still in progress. After aborting, check the working tree and branch state before trying another integration route.

Official documentation

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.