0

The Git documentation (https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches) says: "Remote-tracking branches are references to the state of remote branches...Git moves them for you whenever you do any network communication"

Under what conditions would the remote-tracking branch move upon network communication if you hadn't used 'git fetch' to pull in anything new from the remote?

Nick Koprowicz
  • 153
  • 2
  • 11

1 Answers1

0

Very few Git commands communicate with the remote, in general. Among these, the ones that do update the remote-tracking branches are:

  • git clone
  • git push (mentioned above)
  • git pull (since it runs git fetch)
  • git submodule update (fetches the submodules)
  • git remote update (a command not often taught these days)

I think that’s all for the main "porcelain" commands.

philb
  • 2,031
  • 15
  • 20
  • 1
    I can think of other Git commands that communicate over the network but don't affect the remote tracking branches. So maybe you should edit your opening sentence to say what you mean. – matt May 07 '22 at 18:55
  • And, obvious as it may be, maybe you should list `clone`. – matt May 07 '22 at 18:57
  • My confusion is really about the point of 'git fetch'. My understanding is that that pulls in new changes from the remote and updates the remote-tracking branches. If that's what 'git fetch' does, why would you also want this to happen when you do other network communication? – Nick Koprowicz May 12 '22 at 22:26