git diff origin master 应该做什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22259977/
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-19 09:48:50  来源:igfitidea点击:

What is git diff origin master supposed to do?

gitdiff

提问by Senthil Kumaran

From a git branch, a colleague of mine ran

从 git 分支,我的一个同事跑了

git diff origin master

What is it supposed supposed to do? What does originseparately point to?

它应该做什么?什么是origin单独指向?

This is related, but not covered in In Git, what is the difference between origin/master vs origin master?

这是相关的,但在 Git 中没有涉及, origin/master 与 origin master 之间有什么区别?

采纳答案by torek

This form of git diffjust takes two revision specifiers, as described in gitrevisions.

这种形式git diff只需要两个修订说明符,如gitrevisions 中所述

In this case originis most likely to match item 6:

在这种情况下origin最有可能匹配第 6 项:

6. otherwise, refs/remotes/<refname>/HEADif it exists.

6. 否则,refs/remotes/<refname>/HEAD如果存在。

So this means the same as git diff origin/HEAD master: resolve origin/HEADto a commit-ID, resolve masterto a commit-ID, and diff the two commits.

所以这意味着与git diff origin/HEAD master:解析origin/HEAD为提交 ID,解析master为提交 ID,并区分两个提交。

Run:

跑:

git rev-parse origin

to see how the resolution works.

看看分辨率是如何工作的。

回答by Amos Folarin

"origin" points to the "remote", typically where you cloned the repository from, see

“origin”指向“remote”,通常是您从中克隆存储库的位置,请参阅

$ git remote -v show

But specifically in answer to your question "git diff origin master" is equiv. to this:

但特别是回答你的问题“git diff origin master”是等效的。对此:

$ git diff origin/HEAD master 

origin/HEAD to the branch pointed to by HEAD reference on the remote. Which was the checked out branch at last pull.

origin/HEAD 指向远程 HEAD 引用指向的分支。这是最后拉出的签出分支。

Take a look at your commit graph, which will show you where all your references are (--decorate)

看看你的提交图,它会告诉你所有的引用在哪里(--decorate)

$ git log --oneline --graph --all --decorate

回答by David

It shows the changes between the tips of origin/HEAD and the master branches. You can achieve the same with following commands:

它显示了 origin/HEAD 和 master 分支的提示之间的变化。您可以使用以下命令实现相同的目的:

  • git diff origin/HEAD master
  • git diff origin/HEAD..master
  • git diff 起源/HEAD 大师
  • git diff 起源/HEAD..master

Usually origin points to the source from where you cloned your repository.

通常 origin 指向您克隆存储库的源。

回答by Jan Hudec

It is equivalent to

它相当于

git diff origin/HEAD master

回答by vonbrand

It depends... if originand masterare branches, it shows the difference between them. When looking over explanations, they usually use originto stand for the original (upstream, official, whatever) branch, and masterfor the branch you are working on. I.e., "show me what changed with respect to the original version."

这取决于......如果originmaster是分支,它显示了它们之间的区别。在查看解释时,它们通常用于origin代表原始(上游、官方、任何)分支,以及master您正在处理的分支。即,“向我展示与原始版本相比有哪些变化。”