[英]Order of commit arguments in git diff
In what order does the git command git 命令以什么顺序执行
git diff [--options] <commit> <commit> [--] [<path>…]
Compare the different commits against each other?比较不同的提交? It seems like if I want to compare the new against the old one I need to do
好像如果我想比较新旧我需要做的
git diff [--options] <New_commit> <Old_commit>
in order to see the current diff? git diff [--options] <New_commit> <Old_commit>
以查看当前差异?
I usually do git diff [--options] <Old_commit> <New_commit>
我通常做
git diff [--options] <Old_commit> <New_commit>
But that seems to be wrong?但这似乎是错误的?
When I do for example例如,当我做
$ git diff `git rev-list --since="jun 30 2014" --reverse origin/master | head -1` `git rev-list --until="dec 31 2014" origin/master | head -1` --shortstat
1072 files changed, 389650 insertions(+), 39180 deletions(-)
But when I do但是当我这样做时
$ git diff --stat `git rev-list --until="dec 31 2014" origin/master | head -1`
I get the printout that:我得到的打印输出是:
384 files changed, 61255 insertions(+), 20526 deletions(-)
Which is not near 300000. So my question is if I should insert the new commit first and the old commit sedond, like:这不是接近 300000。所以我的问题是我是否应该先插入新提交和旧提交,例如:
$ git diff `git rev-list --until="dec 31 2014" origin/master | head -1`..`git rev-list --since="jun 30 2014" --reverse origin/master | head -1`
I can't find any documentation about in which order I should insert the commits in order to see the difference between my new and my old commit.我找不到任何关于我应该以何种顺序插入提交以查看我的新提交和旧提交之间的差异的文档。 Perhaps you can clarify this for me?
也许你可以为我澄清这一点?
Thanks in advance.提前致谢。
Edit: The reason I'm asking is that I want to编辑:我问的原因是我想
know how many new lines of code that has been added to a new commit given an old commit, and知道在给定旧提交的情况下已添加到新提交中的新代码行数,以及
I want to calculate the number of lines of code in the new commit.我想计算新提交中的代码行数。
In the following git-diff
syntax, 在下面的
git-diff
语法中,
git diff [--options] <commit> <commit> [--] [<path>...]
<commit>
corresponds to the base commit, <commit>
对应于基本提交, <commit>
corresponds to the commit to compare to the base commit. <commit>
对应于与基本提交进行比较的提交。 Using a mathematically inspired notation, 使用数学启发的符号,
git diff <x> <x+∆x>
will show you the difference ∆x
, whereas 会告诉你差异
∆x
,而
git diff <x+∆x> <x>
will show you the difference -∆x
. 会告诉你差异
-∆x
。
Note that, because the two commits need not be ordered in any way, either chronologically or topologically, calling them "old" and "new" (as you do) is a bit misleading. 请注意,因为两个提交不需要以任何方式排序,无论是按时间顺序还是拓扑结构,称其为“旧”和“新”(如您所做)有点误导。
You can learn a great deal simply by looking up the git-diff
man page . 只需查看
git-diff
手册页,您就可以学到很多东西。 Under the Description section, you'll find 在“ 描述”部分下,您将找到
git diff [--options] <commit> <commit> [--] [<path>...]
This is to view the changes between two arbitrary
<commit>
.这是为了查看两个任意
<commit>
之间的变化。
Granted, that doesn't tell you which commit is which, but, further down, under the Examples section, you'll find a couple of illuminating examples: 当然,这并没有告诉你哪个提交是哪个,但是,在示例部分下面,你会发现一些有启发性的例子:
git diff HEAD^ HEAD
[...] Compare the version before the last commit and the last commit.
[...]比较上次提交和最后一次提交之前的版本。
and 和
git diff topic...master
[...]
[...]
Changes that occurred on the master branch since when the topic branch was started off it.
自主题分支启动以来主分支上发生的更改。
git diff commit_source commit_destination
what the git diff
will show is git diff
将显示什么
commit_source
would bring in if you merged it into commit_destination
commit_source
合并到commit_destination
, commit_source
将带来的更改列表which is not the same as :这与以下内容不同:
commit_source
and commit_destination
commit_source
和commit_destination
之间的所有差异
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.