I am learning Git and am attempting to understand the difference between \"tracking\" a remote and defining an \"upstream\" relationship with it (with the -u
tag).
"Tracking" and "upstream" are related terms. "Tracking" means associating a branch of your local repository with an upstream branch, i.e. a branch that lives in a remote repository. For instance,
git push -u origin newbranch
sets up the tracking information of your local newbranch
so that the newbranch
that lives in the remote repo called origin
(i.e. the remote repo that your local repo knows under the nickname origin
) is considered the upstream branch of your local newbranch
... and carries out the push.
If you obtained your local repository by cloning it, you don't need to run
git push -u origin master
because origin/master
is already set up as master
's upstream branch. In other words, master
is already set to track origin/master
.