How to Fix Git’s “couldn’t find remote ref” Error
When git pull origin feature/logn fails with fatal: couldn't find remote ref feature/logn, there is no branch with that name on the remote. Check the branch names on the remote with git ls-remote --heads origin, then run pull again with the correct name. The error goes away.
This error appears when you mistype a branch name, confuse main with master, or pull a branch that was deleted on the remote. I reproduced the error in a test environment, checked the message, and confirmed that correcting the name made it go away.
The test environment was Ubuntu 24.04, Git 2.43.0, and bash 5.2. For the remote, I used a bare repository created in the same environment, and I first put two branches in it, main and feature/login. I ran the commands with LANG=C so the messages would be in English. In the output, I replaced the remote path with /path/to/…. I did not test pulling from hosting services such as GitHub, and I did not test on Windows or macOS.
- 1. The message when you pull a branch that does not exist
- 2. Pull stops when the name does not match a branch on the remote
- 3. Check the branch names on the remote
- 4. Running pull again with the correct name removes the error
- 5. A branch can still appear in git branch -r after it is deleted on the remote
- 6. Without arguments, git pull shows a different message
The message when you pull a branch that does not exist
I typed feature/logn to pull feature/login, which exists on the remote. I left out the i. The only output was this one line, and the exit code was 1.
$ git pull origin feature/logn
fatal: couldn't find remote ref feature/logn
I compared git log --oneline -1 before and after the pull. Both showed f39804d 最初のコミット. Nothing was fetched, and the local branch did not change. git fetch origin feature/logn produced the same message, but its exit code was 128.
The same message appears when the case is different or when you confuse main with master. The remote has main, but it has neither Main nor master, so both commands stopped.
$ git pull origin Main
fatal: couldn't find remote ref Main
$ git pull origin master
fatal: couldn't find remote ref master
Pull stops when the name does not match a branch on the remote
git pull origin <name> first receives the list of branches and tags from the remote, then looks for the name you specified. In the Git source (remote.c), if no matching ref is found, it prints this message and stops.

Check the branch names on the remote
Add --heads to git ls-remote to list the branches on the remote (git ls-remote reference). The part after refs/heads/ is the name you pass to pull.
$ git ls-remote --heads origin
1f1a799d078e32c00dd6b899a3327179885ed93c refs/heads/feature/login
f39804d63cee12a9dd96e457487f130c25b2b37f refs/heads/main
If there are many branches, you can narrow the list by passing a pattern with * around part of the name, such as '*login*'. Put the pattern in quotes so the shell does not expand it.
$ git ls-remote --heads origin '*login*'
1f1a799d078e32c00dd6b899a3327179885ed93c refs/heads/feature/login
git remote show origin also showed the remote branches under Remote branches:. According to the git remote reference, show queries the remote before displaying the result unless you pass -n.
$ git remote show origin
* remote origin
Fetch URL: /path/to/remote.git
Push URL: /path/to/remote.git
HEAD branch: main
Remote branches:
feature/login tracked
main tracked
(以下、省略)
Running pull again with the correct name removes the error
I ran pull again with feature/login, the name I had confirmed. It showed no error and fetched the changes.
$ git pull origin feature/login
From /path/to/remote
* branch feature/login -> FETCH_HEAD
Updating f39804d..1f1a799
Fast-forward
login.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 login.txt
When the pull had stopped because I specified master, changing it to main showed Already up to date., and the error was gone.
A branch can still appear in git branch -r after it is deleted on the remote
Sometimes origin/feature/old appears in the git branch -r list, but git pull origin feature/old still fails with the same error. git branch -r shows the remote branches recorded during your last fetch. If a branch is deleted on the remote, that record stays until you remove it.
I deleted feature/old on the remote from another clone and then tried again. git branch -r still listed origin/feature/old, and pull stopped.
$ git branch -r
origin/HEAD -> origin/main
origin/feature/login
origin/feature/old
origin/main
$ git pull origin feature/old
fatal: couldn't find remote ref feature/old
I ran git fetch --prune. As described in the git fetch reference, it removed the local records of branches that no longer exist on the remote, and they disappeared from git branch -r. For more on cleaning up branches deleted on the remote, see the separate article "git fetch –prune: cleaning up branches deleted on the remote."
$ git fetch --prune origin
From /path/to/remote
- [deleted] (none) -> origin/feature/old
$ git branch -r
origin/HEAD -> origin/main
origin/feature/login
origin/main
Without arguments, git pull shows a different message
When the upstream branch was deleted on the remote and I ran git pull with no arguments, it stopped with a different message, not couldn't find remote ref. The exit code was 1.
$ git pull
Your configuration specifies to merge with the ref 'refs/heads/feature/cart'
from the remote, but no such ref was fetched.
The upstream of feature/cart was still origin/feature/cart, but feature/cart no longer existed on the remote. After git fetch --prune, git branch -vv showed gone for the upstream.
$ git branch -vv
* feature/cart 2d169fd [origin/feature/cart: gone] カート
main 1f1a799 [origin/main: ahead 1] ログイン画面
Use git branch -u to change the upstream to the remote branch you want to merge from, and this fixes it. As described in the git branch reference, if you omit the branch name, the command changes the upstream of the current branch. I wanted to merge changes from main, so I set the upstream to origin/main. After that, git pull showed Already up to date. and no longer stopped.
$ git branch -u origin/main
branch 'feature/cart' set up to track 'origin/main'.
$ git pull
Already up to date.
After you set the upstream to main, a later git pull with no arguments merges main into this branch. If you do not plan to pull on this branch anymore, you can instead remove the upstream with git branch --unset-upstream rather than changing it. For more on setting and removing upstreams, see the separate article "How to set the upstream branch in Git."




