note about the -u option (long form - --set-upstream ) on the push command, i.e. what is the difference between the team
$ git push origin ветка
from the team
$ git push -u origin ветка
the only difference in the results of these two commands is that the second command (the one with the -u option ( --set-upstream )) will add your local storage to the config file (that is, to the .git/config file .git/config ) section describing the branch ветка :
[branch "ветка"] remote = origin merge = refs/heads/ветка
it is clear that such a section will be added only if it was not there before, i.e. use the option -u ( --set-upstream ) for an individual branch makes sense only once (re-executing the git push -u origin ветка command will not be any different from the git push origin ветка command).
the meaning of this section is that for a branch a ветка indicated:
- from which remote repository (in this case,
origin ) “pull up” changes - from which branch of this repository they “pull up” (in this case, from the
ветка )
and what are the consequences of having such a section?
a visual consequence manifests itself, for example, when executing a command
$ git remote show origin
in the list of branches configured for git pull , you will see a record and a branch about the ветка (besides the already configured master branch):
... Local branches configured for 'git pull': ветка merges with remote ветка master merges with remote master ...
a functional consequence will manifest itself when executing the git pull command when the ветка is current.
if the mentioned section is absent, then you will receive an error message of the following form:
There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch> ветка
- if the section is present, then “normal”
pull will be executed.
git push -ucommand ... or not? or exactly the branches are sent to the repo? - Aleksey Timoshchenko