What does the -u flag mean in git push -u origin m

2019-01-21 21:22发布

问题:

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

git push -u origin master

回答1:

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.



回答2:

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.



标签: git github push