What does the -u flag mean in git push -u origin master?

GitGithubPush

Git Problem Overview


I was just wondering what does the -u flag mean in this command?

git push -u origin master

Git Solutions


Solution 1 - Git

The -u option does the following: For every branch that is up to date or successfully pushed, add an upstream (tracking) reference, used by argument-less, git-pull and other commands.

So, after pushing your local branch with the -u option, this local branch will be automatically linked with the remote branch, and you can use git pull without any arguments.

Solution 2 - Git

It's the same as --set-upstream

It's used to set origin as the upstream remote in your git config.

It may help if you don't want to manually specify the remote every time you run git push.

Also ...

As you're new to stackOverflow, take your time to read What types of questions should I avoid asking? section of the Help because sometimes you can find the answers by simply browsing the documentation.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser123456View Question on Stackoverflow
Solution 1 - GitShunyaView Answer on Stackoverflow
Solution 2 - GitAhmed SiouaniView Answer on Stackoverflow