0

I am trying to set git branch upstream but getting below warning.

Command

git checkout master
git branch --set-upstream-to master

warning: Not setting branch master as its own upstream.

How can I solve it?

Does that mean it already being tracing correct remote branch master?

Community
  • 1
  • 1
Sazzad Hissain Khan
  • 29,428
  • 20
  • 134
  • 192

1 Answers1

3

That should be:

 git branch --set-upstream-to origin/master

But if origin/master is there, the checkout should have tracked it already.

If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name and --no-guess is not specified, treat as equivalent to:

$ git checkout -b <branch> --track <remote>/<branch>

With Git 2.23+, you would use git switch master instead of checkout, as I mentioned here.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • Why would anyone want to set a local branch as the upstream? – Unknow0059 Jan 12 '21 at 06:21
  • 1
    @Unknow0059 maybe because that person has missed the concept of "upstream" and "remotes", as defined in https://stackoverflow.com/a/2749166/6309 and https://stackoverflow.com/a/9257901/6309 – VonC Jan 12 '21 at 07:13
  • So it's technically possible for you to set any repository as the upstream, it's just not the convention. – Unknow0059 Jan 12 '21 at 09:04
  • @Unknow0059 there can be cases to do so, like one working offline for some experimental works. – Sazzad Hissain Khan Feb 17 '21 at 02:57