0

My coworker pushed out a branch called xianx/update2023, and I made a local branch to try and track it. However, I keep getting this error when I try to set the upstream of my branch to theirs.

D:\src\Demo\Models>git branch -u origin/xianx/update2023
error: the requested upstream branch 'origin/xianx/update2023' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.

I checked to make sure that the remote branch does indeed exist.

D:\src\Demo\Models>git ls-remote origin
b6b5157e605f0c20f373f9a6c484b94c2553d7e4        refs/heads/xianx/update2023

But git fetch just returns an empty newline and does not resolve the problem.

D:\src\Demo\Models>git fetch

I tried the solution here to use git fetch upstream, but it's not working either.

D:\src\Demo\Models>git fetch upstream master:master
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

D:\src\Demo\Models>git fetch upstream
fatal: 'upstream' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
wheeeee
  • 1,046
  • 2
  • 14
  • 33
  • sounds like you've got your fetch set to a single branch. What's `git config --get-regexp fetch` say? – jthill Mar 09 '23 at 01:43
  • "*`git fetch upstream` fatal: 'upstream' does not appear to be a git repository*" Try `git fetch origin`. "origin" is the default name for the upstream (the 1st remote repo); "upstream" is usually the 2nd remote, the "origin" of the "origin". In your case the repository doesn't have "upstream" remote but has "origin". – phd Mar 09 '23 at 05:42
  • @phd something felt odd, so I tried `git init testit; cd testit; git fetch`. It seems `git fetch` is silent if there is no origin. OP, you have to tell Git about any other repositories you want to talk to, `git clone` assumes you want to talk to the one you fetched your starter history from and sets up the `origin` remote, have you done that? – jthill Mar 09 '23 at 06:31
  • @jthill `git ls-remote origin` works for the OP. – phd Mar 09 '23 at 06:40
  • @phd oh. right. "I knew that." . – jthill Mar 09 '23 at 06:51

0 Answers0