4

sometimes, git will spontaneously (during some, but not all, "pull" or "clone" operations) copy all of the remote branches of a repository into my local repository (and even set them all up to track the corresponding remote branches correctly). What causes this? Is there a way I can do this on purpose?

jes5199
  • 18,324
  • 12
  • 36
  • 40

2 Answers2

5

If you just do a normal branch from a remote branch, it'll track by default:

git checkout -b somebranch origin/somebranch

means roughly the same thing as

git checkout -t origin/somebranch

You pretty much have to explicitly tell it if you don't want such tracking.

Dustin
  • 89,080
  • 21
  • 111
  • 133
0

If you know the name of the remote branch you want to track, you can just do:

git checkout somebranch

It will say something like:

Branch somebranch set up to track remote branch badges from origin.