git push -u origin master 中的 -u 标志是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18867824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:59:46  来源:igfitidea点击:

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

gitgithubpush

提问by user123456

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

我只是想知道-u这个命令中的标志是什么意思?

git push -u origin master

采纳答案by Shunya

The -uoption 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.

-u选项执行以下操作:对于每一个分支是最新的或成功推,添加上游(跟踪)参考,由参数少的git拉丝及其他命令使用。

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

因此,在使用-u选项推送本地分支后,此本地分支将自动与远程分支链接,您可以不带任何参数使用 git pull。

回答by Ahmed Siouani

It's the same as --set-upstream

它与 --set-upstream

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

它用于在您的 git 配置中将 origin 设置为上游远程。

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

如果您不想在每次运行 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 Helpbecause sometimes you can find the answers by simply browsing the documentation.

由于您是stackOverflow 的新手,请花点时间阅读我应该避免问哪些类型的问题?一节的帮助,因为有时你可以通过简单的浏览找到答案的文档