git diff merge-base with working tree(使用 ... 表示法)
git diff merge-base with working tree (using ... notation)
(与 Git diff branch against working tree not including merges 的问题略有不同)
基本上我想要git diff origin/develop...working-tree
。
从技术上讲,我想要的是 git diff $(git-merge-base origin/develop HEAD)
,它将根据工作树区分合并基础;但是我想同时保留...
shorthand。
origin/develop...
部分计算正确的合并基础(合并基础与 HEAD),但它也被硬编码为假设 comparison 是针对 HEAD 的出色地。有没有办法保留 ...
shorthand 参考,但与工作树不同?
没有。您不能将简写符号与针对工作树的差异结合起来。您必须使用较长的形式。
您可以制作一个 Git 别名来调用 shell:
alias.basevtree=!git diff $(git merge-base @{u} HEAD)
(我不确定你的 ^
在那里做什么)然后 运行 git basevtree
,但是你不能用三点语法得到它。
2020 年 11 月更新:是的,现在可以了。
运行 git diff --merge-base <commit>
等同于 运行 git diff $(git merge-base <commit> HEAD)
这应该让你在 merge-base 和当前工作树之间有所区别。
使用 Git 2.30(2021 年第一季度),“git diff A...B
(man)" learned "git diff --merge-base A B
(man),这是一个更长的 short-hand 来表达同样的事情。
参见 commit cce7d6e, commit 0f5a1d4, commit df7dbab, commit 177a830, commit 4c3fe82 (20 Sep 2020), commit 3d09c22 (14 Sep 2020), and commit 308d7a7, commit a8fa6a0, commit b277b73, commit 8023a5e (17 Sep 2020) by Denton Liu (Denton-L
)。
(由 Junio C Hamano -- gitster
-- in commit b6fb70c 合并,2020 年 11 月 2 日)
builtin/diff-index
: learn --merge-base
Signed-off-by: Denton Liu
There is currently no easy way to take the diff between the working tree or index and the merge base between an arbitrary commit and HEAD.
Even diff's ...
notation doesn't allow this because it only works between commits.
However, the ability to do this would be desirable to a user who would like to see all the changes they've made on a branch plus uncommitted changes without taking into account changes made in the upstream branch.
Teach diff-index and diff (with one commit) the --merge-base
option which allows a user to use the merge base of a commit and HEAD as the "before" side.
'git diff-index' [-m] [--cached] [--merge-base] [<common diff options>] <tree-ish> [<path>...]
git diff-index
现在包含在其 man page 中:
--merge-base
Instead of comparing <tree-ish>
directly, use the merge base
between <tree-ish>
and HEAD instead.
<tree-ish>
must be a commit.
git diff
现在包含在其 man page 中:
If --merge-base
is given, instead of using <commit>
, use the merge base
of <commit>
and HEAD
.
git diff --merge-base A
is equivalent to git diff $(git merge-base A HEAD)
.
git diff
现在包含在其 man page 中:
in the --merge-base
case and in the last two forms that use ..
notations, can be any <tree>
.
并且:
builtin/diff-tree
: learn --merge-base
Signed-off-by: Denton Liu
The previous commit introduced --merge-base
a way to take the diff between the working tree or index and the merge base between an arbitrary commit and HEAD.
It makes sense to extend this option to support the case where two commits are given too and behave in a manner identical to git diff A...B
(man).
Introduce the --merge-base
flag as an alternative to triple-dot notation.
Thus, we would be able to write the above as git diff --merge-base A B
(man).
git diff-tree
现在包含在其 man page 中:
--merge-base
Instead of comparing the <tree-ish>
s directly, use the merge
base between the two <tree-ish>
s as the "before" side.
There must be two <tree-ish>
s given and they must both be commits.
git diff
现在包含在其 man page 中:
If --merge-base
is given, use the merge base of the two commits for the
"before" side.
git diff --merge-base A B
is equivalent to git diff $(git merge-base A B) B
.
随着 Git 2.33(2021 年第 3 季度),“git diff
"(man) --merge-base
文档已更新。
参见 commit eb44863 (10 Jul 2021) by Denton Liu (Denton-L
)。
(由 [=109= 合并],2021 年 7 月 28 日)
git-diff
: fix missing --merge-base docs
Signed-off-by: Denton Liu
When git diff --merge-base
(man) was introduced at around Git 2.30, the documentation included a few errors.
In the example given for git diff
--cached
--merge-base, the --cached
flag was omitted for the --merge-base
example.
Add the missing flag.
In the git diff
<commit>
case, we failed to mention that --merge-base
is an available option.
Give the usage of --merge-base
as an option there.
Finally, there are two errors in the usage of git diff
.
Firstly, we do not mention --merge-base
in the git diff
--cached
case.
Mention it so that it's consistent with the documentation.
Secondly, we put the [--merge-base]
in between <commit>
and [<commit>...]
.
Move the [--merge-base]
so that it's beside [<options>]
which is a more logical grouping.
git diff
现在包含在其 man page 中:
git diff --cached --merge-base A
is equivalent to
git diff --cached $(git merge-base A HEAD)
.
git diff
现在包含在其 man page 中:
'git diff' [<options>] [--merge-base] <commit> [--] [<path>...]
git diff
现在包含在其 man page 中:
If --merge-base
is given, instead of using <commit>
, use the merge base
of <commit>
and HEAD.
git diff --merge-base A
is equivalent to git diff $(git merge-base A HEAD)
.
(与 Git diff branch against working tree not including merges 的问题略有不同)
基本上我想要git diff origin/develop...working-tree
。
从技术上讲,我想要的是 git diff $(git-merge-base origin/develop HEAD)
,它将根据工作树区分合并基础;但是我想同时保留...
shorthand。
origin/develop...
部分计算正确的合并基础(合并基础与 HEAD),但它也被硬编码为假设 comparison 是针对 HEAD 的出色地。有没有办法保留 ...
shorthand 参考,但与工作树不同?
没有。您不能将简写符号与针对工作树的差异结合起来。您必须使用较长的形式。
您可以制作一个 Git 别名来调用 shell:
alias.basevtree=!git diff $(git merge-base @{u} HEAD)
(我不确定你的 ^
在那里做什么)然后 运行 git basevtree
,但是你不能用三点语法得到它。
2020 年 11 月更新:是的,现在可以了。
运行 git diff --merge-base <commit>
等同于 运行 git diff $(git merge-base <commit> HEAD)
这应该让你在 merge-base 和当前工作树之间有所区别。
使用 Git 2.30(2021 年第一季度),“git diff A...B
(man)" learned "git diff --merge-base A B
(man),这是一个更长的 short-hand 来表达同样的事情。
参见 commit cce7d6e, commit 0f5a1d4, commit df7dbab, commit 177a830, commit 4c3fe82 (20 Sep 2020), commit 3d09c22 (14 Sep 2020), and commit 308d7a7, commit a8fa6a0, commit b277b73, commit 8023a5e (17 Sep 2020) by Denton Liu (Denton-L
)。
(由 Junio C Hamano -- gitster
-- in commit b6fb70c 合并,2020 年 11 月 2 日)
builtin/diff-index
: learn--merge-base
Signed-off-by: Denton Liu
There is currently no easy way to take the diff between the working tree or index and the merge base between an arbitrary commit and HEAD.
Even diff's...
notation doesn't allow this because it only works between commits.However, the ability to do this would be desirable to a user who would like to see all the changes they've made on a branch plus uncommitted changes without taking into account changes made in the upstream branch.
Teach diff-index and diff (with one commit) the
--merge-base
option which allows a user to use the merge base of a commit and HEAD as the "before" side.'git diff-index' [-m] [--cached] [--merge-base] [<common diff options>] <tree-ish> [<path>...]
git diff-index
现在包含在其 man page 中:
--merge-base
Instead of comparing
<tree-ish>
directly, use the merge base between<tree-ish>
and HEAD instead.
<tree-ish>
must be a commit.
git diff
现在包含在其 man page 中:
If
--merge-base
is given, instead of using<commit>
, use the merge base of<commit>
andHEAD
.
git diff --merge-base A
is equivalent togit diff $(git merge-base A HEAD)
.
git diff
现在包含在其 man page 中:
in the
--merge-base
case and in the last two forms that use..
notations, can be any<tree>
.
并且:
builtin/diff-tree
: learn --merge-baseSigned-off-by: Denton Liu
The previous commit introduced
--merge-base
a way to take the diff between the working tree or index and the merge base between an arbitrary commit and HEAD.It makes sense to extend this option to support the case where two commits are given too and behave in a manner identical to
git diff A...B
(man).Introduce the
--merge-base
flag as an alternative to triple-dot notation.Thus, we would be able to write the above as
git diff --merge-base A B
(man).
git diff-tree
现在包含在其 man page 中:
--merge-base
Instead of comparing the
<tree-ish>
s directly, use the merge base between the two<tree-ish>
s as the "before" side.
There must be two<tree-ish>
s given and they must both be commits.
git diff
现在包含在其 man page 中:
If
--merge-base
is given, use the merge base of the two commits for the "before" side.
git diff --merge-base A B
is equivalent togit diff $(git merge-base A B) B
.
随着 Git 2.33(2021 年第 3 季度),“git diff
"(man) --merge-base
文档已更新。
参见 commit eb44863 (10 Jul 2021) by Denton Liu (Denton-L
)。
(由 [=109= 合并],2021 年 7 月 28 日)
git-diff
: fix missing --merge-base docsSigned-off-by: Denton Liu
When
git diff --merge-base
(man) was introduced at around Git 2.30, the documentation included a few errors.In the example given for
git diff
--cached
--merge-base, the--cached
flag was omitted for the--merge-base
example.
Add the missing flag.In the
git diff
<commit>
case, we failed to mention that--merge-base
is an available option.
Give the usage of--merge-base
as an option there.Finally, there are two errors in the usage of
git diff
.
Firstly, we do not mention--merge-base
in thegit diff
--cached
case.
Mention it so that it's consistent with the documentation.
Secondly, we put the[--merge-base]
in between<commit>
and[<commit>...]
.
Move the[--merge-base]
so that it's beside[<options>]
which is a more logical grouping.
git diff
现在包含在其 man page 中:
git diff --cached --merge-base A
is equivalent togit diff --cached $(git merge-base A HEAD)
.
git diff
现在包含在其 man page 中:
'git diff' [<options>] [--merge-base] <commit> [--] [<path>...]
git diff
现在包含在其 man page 中:
If
--merge-base
is given, instead of using<commit>
, use the merge base of<commit>
and HEAD.
git diff --merge-base A
is equivalent togit diff $(git merge-base A HEAD)
.