---
title: "A global remote.origin.fetch refspec creates a phantom 'origin' remote in every repo"
url: "https://www.dariuszparys.com/notes/global-remote-origin-fetch-creates-phantom-remote"
author: "Dariusz Parys"
published: 2026-12-04T00:00:00.000Z
description: "Putting pull-request fetch refspecs under remote.origin in the global gitconfig makes git report a remote named origin without a URL in every repository, including new ones that have no remote."
tags:
  - "Git"
  - "Shell"
---

# A global remote.origin.fetch refspec creates a phantom 'origin' remote in every repo

## Context

A common dotfiles trick is to fetch pull-request branches in every repository by putting the refspecs in the global gitconfig:

```
[remote "origin"]
    fetch = +refs/pull/*/head:refs/remotes/origin/pr/head/*
    fetch = +refs/pull/*/merge:refs/remotes/origin/pr/merge/*
```

## Insight

Git reads every config level and merges them, so **every repository now has a remote named `origin`**, even a freshly initialised one with no remote. It has fetch rules but no URL:

```bash
git init demo && cd demo
git remote -v
# origin	        <- no URL
```

That surprises scripts, agents and people who read `git remote -v` or `git config remote.origin.*` to decide whether a repo already has a remote.

What I checked (git 2.55): `git remote add origin <url>` still works. It writes the URL and the default `+refs/heads/*:refs/remotes/origin/*` refspec into `.git/config`, and the global pull-request refspecs keep applying on top. Not tested: tools that refuse to create a remote that "already exists", such as `gh repo create --source . --remote origin`. When in doubt, set the URL in the repository's own config instead:

```bash
git config remote.origin.url <url>
git config --add remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
```

Find where a phantom remote comes from:

```bash
git config --show-origin --get-regexp '^remote\.'
```

## Docs

A docs check did not find this behaviour described on these pages (no claim beyond them):

- [git-config](https://git-scm.com/docs/git-config)
- [git-remote](https://git-scm.com/docs/git-remote)
- [git-fetch](https://git-scm.com/docs/git-fetch)
- [Checking out pull requests locally (GitHub Docs)](https://docs.github.com/en/pull-requests/how-tos/review-pull-requests/checking-out-pull-requests-locally)
