Что значит git push -u? - PullRequest
       3

Что значит git push -u?

310 голосов
/ 06 апреля 2011

У меня есть две разные версии git.В версии 1.6.2 git push не имеет опции -u.Он появляется только в версии 1.7.x.

Из документов -u относится к переменной

branch.<name>.merge

в git config.Эта переменная описана ниже:

Defines, together with branch.<name>.remote, the upstream branch 
for the given branch. It tells git fetch/git pull which branch to merge.

Что такое восходящая ветвь?

Ответы [ 2 ]

341 голосов
/ 06 апреля 2011

«Вверх по течению» означает основной репо, из которого будут вытягивать другие люди, например, ваш репозиторий GitHub. Опция -u автоматически устанавливает этот апстрим для вас, связывая ваш репо с центральным. Таким образом, в будущем Git «знает», куда вы хотите нажать и куда вы хотите получить, поэтому вы можете использовать git pull или git push без аргументов. Немного вниз, эта статья объясняет и демонстрирует эту концепцию.

9 голосов
/ 08 июня 2015

Это больше не актуально!

Push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...