3

I learned git pull does a git fetch followed by a git merge

But I create a branch in upstream. The branch reflected in my fork too.

In my local, I did a git pull and did a git branch -a where I did not see that branch.

Only when I did a git fetch I saw the branch in my local.

Why is that?

xingbin
  • 27,410
  • 9
  • 53
  • 103
Harshana
  • 7,297
  • 25
  • 99
  • 173

1 Answers1

2

git pull mentions:

More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch.

And those parameters, by default are:

Default values for <repository> and <branch> are read from the "remote" and "merge" configuration for the current branch as set by git-branch --track.

That involves only one branch, and differs from git fetch used directly, which by default uses:

+refs/heads/*:refs/remotes/origin/*

That is the usual config setting for a cloned repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250