Home git What is the destination of the `-u -u key` During Git Push?

What is the destination of the `-u -u key` During Git Push?




And what is distinguished by sending without a key Git Push Origin Master .

Answer 1, Authority 100%

If you do Git Push Branches without a key -u , Git will not connect the local branch with a branch of the remote repository. The following operation Git Pull in this branch will be unsuccessful, as Git will not know from which removed branch to tighten the changes, it will have to specify explicitly using the Git Branch --Set-Upstream-to = ORIGIN / MASTER . Meaning to use the -u key only with the lips of new branches, for existing (associated with remote) branches each time, overwritten a bundle.

Answer 2, Authority 100%

with -U key (full version - set-upstream ) you create (if there is no) in the remote repository a branch corresponding to your local and link them:

  • in Remote / BranchName will be made in the local branch of BranchName
  • from Remote / BranchName will be produced in the local branch of Branchname

For Master This is relevant only if you fighten in an empty repository. If cloned – the branches are already configured. But as soon as you create a new local branch and want to run it on Remote, you will need the -u key.

# own a local branch
Git Checkout -B Mybranch
# Create a branch on Remote
Git Push -u Origin Mybranch
# You can choose another name for the breed created on Remote.
Git Push -u Origin Mybranch_With_Other_Name

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions