0

After push a local branch to remote WITHOUT --set-upstream parameter, I found the remote branch is tracked, but the local branch has no upstream branch. Aren't track and upstream the same meaning? what's difference if not?(git version 2.27.0.windows.1)

  1. create branch

    $ git branch testing

  2. push local branch to remote

    $ git checkout testing

    $ git push origin testing

  3. push changes, but looks like no upstream at all.

    $ git push

    fatal: The current branch testing has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin testing

  4. but in the detail of remote origin, the remote branch testing is tracked. enter image description here

What's the difference between tracked and upstream? I doesn't understand current status: the remote branch tracked but the local branch has no upstream.

Community
  • 1
  • 1
CQLI
  • 413
  • 4
  • 11

2 Answers2

2

The command you display is the output of git remote show.

See @torek's explanations here :
“git remote show origin”: why all branches show “tracked” even when some aren't?

Wiith this command, "tracked" means that the branch will be downloaded to a local origin/* ref (note : this is not explicitly stated in the docs, and is indeed misleading).

If you want to see "what local branch tracks what remote branch" :

use git branch -vv, or check the content of your .git/config (git config -l | grep branch or git config --get-regexp '^branch\.')

LeGEC
  • 46,477
  • 5
  • 57
  • 104
1

tl;dr: your local branch isn't tracking a remote yet, but your remote copy is tracking the branch on origin.

Details:

There are 3 buckets:

  1. Your local branch.
  2. Your copy of the remote branch.
  3. The actual remote branch.

Setting your local branch to "track" an upstream branch links #1 and #2. From the remote's point of view, "tracked" means #2 exists and is linked to #3.

In the context of the command:

git remote show origin

"tracked" means that you have a copy of that branch in your copy of the remote. Note if someone else adds a branch and you haven't fetched it yet, instead of "tracked" you will see "new". When you pushed out your local branch for the first time, your remote branch began tracking origin's branch, but you didn't set your local copy to track the remote branch. Had you done "push -u" you would have also set the upstream tracking branch to the remote.

TTT
  • 22,611
  • 8
  • 63
  • 69