There is no difference at all!
1) git checkout -b branch origin/branch
If there is no --track
and no --no-track
, --track
is assumed as default. The default can be changed with the setting branch.autosetupmerge
.
In effect, 1) behaves like git checkout -b branch --track origin/branch
.
2) git checkout --track origin/branch
“As a convenience”, --track
without -b
implies -b
and the argument to -b
is guessed to be “branch”. The guessing is driven by the configuration variable remote.origin.fetch
.
In effect, 2) behaves like git checkout -b branch --track origin/branch
.
As you can see: no difference.
But it gets even better:
3) git checkout branch
is also equivalent to git checkout -b branch --track origin/branch
if “branch” does not exist yet but “origin/branch” does1.
All three commands set the “upstream” of “branch” to be “origin/branch” (or they fail).
Upstream is used as reference point of argument-less git status
, git push
, git merge
and thus git pull
(if configured like that (which is the default or almost the default)).
E.g. git status
tells you how far behind or ahead you are of upstream, if one is configured.
git push
is configured to push the current branch upstream by default2 since git 2.0.
1 ...and if “origin” is the only remote having “branch”
2 the default (named “simple”) also enforces for both branch names to be equal