How to fix fatal: No such remote 'upstream' in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 154 views

This error occurs when you try to perform an operation on a remote named 'upstream' that doesn't exist in your Git repository. You need to add the upstream remote before using it, typically when working with a forked repository.

Quick fix

Fixes fatal: No such remote 'upstream'

git remote -v
  1. Check your current remotes
  2. Add the upstream remote
  3. Verify the upstream remote was added
  4. Fetch from upstream
git โ€” error
git remote -v
fatal: No such remote 'upstream'

What this error means

The "fatal: No such remote 'upstream'" error indicates that Git cannot find a remote repository with the name "upstream" in your local repository's configuration. This usually happens when you're working with a forked repository and trying to sync changes from the original repository. When you fork a repository on GitHub, GitLab, or Bitbucket, your fork only has one remote configured by default: "origin" (pointing to your fork). The "upstream" remote is a conventional name used to reference the original repository that you forked from, but it must be manually added. This error commonly appears when: - Following a tutorial that assumes upstream is already configured - Running `git fetch upstream` or `git pull upstream main` on a fork - Trying to sync your fork with the original repository - Copying commands from documentation without setting up the remote first

Typical symptoms

  • Running 'git fetch upstream' fails with 'No such remote'
  • Running 'git pull upstream main' fails with 'No such remote'
  • Cannot sync fork with the original repository
  • Git remote commands fail when referencing 'upstream'
  • Scripts or CI/CD pipelines fail when trying to access upstream

Common causes

  1. The 'upstream' remote was never added to the repository
  2. Working with a forked repository without configuring the original as upstream
  3. Typo in the remote name (e.g., 'upstrem' instead of 'upstream')
  4. The remote was removed or renamed
  5. Cloned the fork instead of the original repository without setting up remotes
  6. Following tutorial instructions that assume upstream already exists

How to fix "fatal: No such remote 'upstream'"

1Check your current remotes

First, see what remotes are currently configured in your repository:

bash
git remote -v

Typical output for a fork (before adding upstream):

bash
origin  git@github.com:YOUR-USERNAME/REPO.git (fetch)
origin  git@github.com:YOUR-USERNAME/REPO.git (push)

If you only see "origin", that's your fork. You need to add "upstream" to reference the original repository.

If you see no remotes at all:

bash
# Your repository has no remotes configured
git remote -v
# (no output)

This means you need to add both origin and upstream.

2Add the upstream remote

Add the original repository as the upstream remote:

bash
git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPO.git

For SSH (if you have SSH keys configured):

bash
git remote add upstream git@github.com:ORIGINAL-OWNER/ORIGINAL-REPO.git

Examples:

bash
# If you forked facebook/react
git remote add upstream https://github.com/facebook/react.git

# If you forked microsoft/vscode
git remote add upstream https://github.com/microsoft/vscode.git

Where to find the original repository URL:
1. Go to your fork on GitHub/GitLab/Bitbucket
2. Look for "forked from ORIGINAL-OWNER/ORIGINAL-REPO" below the repository name
3. Click on that link to go to the original repository
4. Copy its URL from the address bar or the "Code" button

3Verify the upstream remote was added

Confirm that upstream is now configured:

bash
git remote -v

Expected output after adding upstream:

bash
origin    git@github.com:YOUR-USERNAME/REPO.git (fetch)
origin    git@github.com:YOUR-USERNAME/REPO.git (push)
upstream  https://github.com/ORIGINAL-OWNER/REPO.git (fetch)
upstream  https://github.com/ORIGINAL-OWNER/REPO.git (push)

You should now see both "origin" (your fork) and "upstream" (the original repository).

4Fetch from upstream

Now you can fetch updates from the original repository:

bash
git fetch upstream

Expected output:

bash
remote: Enumerating objects: 50, done.
remote: Counting objects: 100% (50/50), done.
remote: Compressing objects: 100% (25/25), done.
Unpacking objects: 100% (50/50), done.
From github.com:ORIGINAL-OWNER/REPO
 * [new branch]      main       -> upstream/main
 * [new branch]      develop    -> upstream/develop

This downloads the latest commits from upstream without merging them into your local branches.

5Sync your fork with upstream

To update your local branch with changes from upstream:

bash
# Switch to your main branch
git checkout main

# Merge upstream changes into your local main
git merge upstream/main

# Push the updates to your fork (origin)
git push origin main

Alternative: Rebase instead of merge (cleaner history):

bash
git checkout main
git rebase upstream/main
git push origin main --force-with-lease

Note: Use --force-with-lease instead of --force for safer force-pushing that won't overwrite others' changes.

6Fix incorrect remote URL

If the upstream remote exists but has the wrong URL, update it:

bash
# Check current URL
git remote get-url upstream

# Update to correct URL
git remote set-url upstream https://github.com/CORRECT-OWNER/CORRECT-REPO.git

Common mistakes to check:
- Repository was renamed or moved to a different organization
- Typo in the owner or repository name
- Using HTTP instead of HTTPS or SSH
- The original repository was deleted

7Remove and re-add upstream if needed

If there are issues with the upstream configuration, remove it and add it fresh:

bash
# Remove the problematic upstream remote
git remote remove upstream

# Add it again with the correct URL
git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPO.git

# Verify the configuration
git remote -v

This is useful when:
- The URL was set incorrectly
- You need to switch between HTTPS and SSH
- The remote configuration is corrupted

Advanced notes

Understanding Git Remotes:

Git remotes are named references to remote repositories. By convention:
- origin: Points to your own repository (typically your fork)
- upstream: Points to the original repository you forked from

These names are conventions, not requirements. You could use any name, but following conventions makes it easier for others to understand your setup.

Working with Multiple Remotes:

You can have many remotes configured:

bash
git remote add upstream https://github.com/original/repo.git
git remote add colleague https://github.com/colleague/repo.git
git remote add backup git@gitlab.com:user/repo.git

GitHub CLI Shortcut:

If you're using GitHub CLI, you can set up remotes more easily:

bash
# Clone your fork and automatically set up upstream
gh repo fork ORIGINAL-OWNER/REPO --clone

# Or, if you already cloned, sync with upstream
gh repo sync

Listing Remote Branches:

After adding upstream, see what branches are available:

bash
# List all remote branches
git branch -r

# List only upstream branches
git branch -r | grep upstream

Keeping Fork Updated Regularly:

Set up a script or alias for regular syncing:

bash
# Add to ~/.bashrc or ~/.zshrc
alias sync-fork='git fetch upstream && git checkout main && git merge upstream/main && git push origin main'

GitHub's "Fetch upstream" Button:

On GitHub, you can also sync your fork through the web interface:
1. Go to your fork on GitHub
2. Click "Fetch upstream" (or "Sync fork") above the file list
3. Click "Fetch and merge"

This updates the default branch on GitHub without using the command line.

Frequently asked questions

What does "fatal: No such remote 'upstream'" mean?
The "fatal: No such remote 'upstream'" error indicates that Git cannot find a remote repository with the name "upstream" in your local repository's configuration. This usually happens when you're working with a forked repository and trying to sync changes from the original repository. When you fork a repository on GitHub, GitLab, or Bitbucket, your fork only has one remote configured by default: "origin" (pointing to your fork).
How do I fix "fatal: No such remote 'upstream'"?
This error occurs when you try to perform an operation on a remote named 'upstream' that doesn't exist in your Git repository. You need to add the upstream remote before using it, typically when working with a forked repository.
What causes "fatal: No such remote 'upstream'"?
The 'upstream' remote was never added to the repository Working with a forked repository without configuring the original as upstream Typo in the remote name (e.g., 'upstrem' instead of 'upstream')
Is the "fatal: No such remote 'upstream'" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading