As I can see, both git --track and --set-upstream-to modify a branch so it becames a tracking (or upstream) branch. But where is a subtle differenc
$ git checkout foo -b
$ git branch --track origin/retarget
The first two commands instruct git to:
origin/retarget" (very bad idea, as it is named as a remote tracking branch", while it is actually a simple local branch with a '/' in its name)foo", another local branch)See git branch
--track
When creating a new branch, set up
branch.and.remote branch.configuration entries to mark the start-point branch as "upstream" from the new branch..merge
You would use track when you create a branch starting from a remote tracking one.
In other word, your first example isn't how you would use --track.
This would work better:
git checkout -b foo --track origin/retarget
As for the difference between --track and --set-upstream-to:
--set-upstream-to
If specified branch does not exist yet or if
--forcehas been given, acts exactly like--track.
Otherwise sets up configuration like--trackwould when creating the branch, except that where branch points to is not changed.