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

user123456 picture user123456 · Sep 18, 2013 · Viewed 43.1k times · Source

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

git push -u origin master

Answer

Shunya picture Shunya · Sep 18, 2013

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

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