我怎样才能得到“git show”?用完整的上下文显示差异? [英] How can I get "git show" to show diffs with full context?
问题描述
我正在审查一个非常古老的提交。我希望看到特定提交所做的更改,但我希望在完整的背景下看到这一点,即我希望看到整个文件以及此人所做的更改。以下命令:
git show -w< commit-id>
没有显示完整的上下文。任何建议?
git-show
附带以下标志
-U n,--unified =< n>
使用< n>生成差异而不是通常的
三种情况。意味着-p。
请参阅 git-show
手册页了解更多详情。
通过指定一个足够大的< n>
,例如
git show -U1000< object>
您将获得完整的上下文。
示例
为了本示例克隆一些存储库(例如 Git项目的回购):
$ git clone https:// github。 com / git / git
$ cd git
尝试在某些提交上运行有问题的命令文件(例如 Documentation / RelNotes / 2.3.0.txt
):
$ git show -U100 - Documentation / RelNotes / 2.3.0.txt
commit 1e6f5b22ad318446500fbd3b94b733eddd5b6414
作者:Junio C Hamano< gitster@pobox.com>
日期:Wed 1月7日13:12:54 2015 -0800
第四批2.3循环
签名:Junio C Hamano< gitster @ pobox.com>
diff --git a / Documentation / RelNotes / 2.3.0.txt b / Documentation / RelNotes / 2.3.0.txt
index 1b1dcbb..7f25bbf 100644
- - a / Documentation / RelNotes / 2.3.0.txt
+++ b / Documentation / RelNotes / 2.3.0.txt
@@ -1,165 +1,247 @@
Git v2.3发行说明
======================
自v2.2以来的更新
----- -------------
端口
* Cygwin最近的gcc工具链开始抛出编译警告,
被压制。
UI,工作流程&特性
*当用户希望
将一组额外的参数传递给底层ssh时,使用GIT_SSH机制非常麻烦。新的
环境变量GIT_SSH_COMMAND可用于此目的。
*通过git notes存储空注释的请求意味着从对象中删除
注释,但使用--allow-empty我们将存储
(意外! )注意是空的。
*git interpret-trailers学会正确处理
Conflicts:块。
*git amlearn--message-id选项将
的消息ID复制到所产生提交的日志消息中。
+ *git clone --reference =<在那里>学会了--dissociate
+选项以配合它;它借用参考对象
+ store中的对象,而克隆仅用于减少网络流量,然后
+通过执行
+借用对象的本地副本将结果克隆与参考解离。
+
*git send-email通过学习--transfer-encoding选项强制
非错误Content-Transfer-Encoding头(例如base64)。
...
完整性检查
比较该命令的输出与 Documentation / RelNotes / 2.3.0.txt
的内容。
$ cat Documentation / RelNotes / 2.3.0.txt
Git v2.3发行说明
======== ==============
自v2.2以来的更新
------------------
端口
* Cygwin最近的gcc工具链开始抛出编译警告,
被压制。
UI,工作流程&特性
*当用户希望
将一组额外的参数传递给底层ssh时,使用GIT_SSH机制非常麻烦。新的
环境变量GIT_SSH_COMMAND可用于此目的。
*通过git notes存储空注释的请求意味着从对象中删除
注释,但使用--allow-empty我们将存储
(意外! )注意是空的。
*git interpret-trailers学会正确处理
Conflicts:块。
*git amlearn--message-id选项将
的消息ID复制到所产生提交的日志消息中。
*git clone --reference =< over there>学会了--dissociate
选项以配合它;它借用参考对象
store中的对象,而克隆仅用于减少网络流量,然后
通过执行借用对象的
本地副本来从参考中分离出结果克隆。
*git send-email通过学习--transfer-encoding选项强制
非错误Content-Transfer-Encoding头(例如base64)。
*git send-email通常通过X-Mailer标识自己:
中的标题它发送的消息。新的命令行标志--no-xmailer
允许用户压制标题。
*git push到工作树的仓库通常会拒绝
来修改签出的分支。学到
的命令可选地仅在
没有改变工作树和索引时才做相当于git reset --hard的命令,而
对于部署通过推入一个存储库。
*git new-workdir(在contrib /中)可以用来填充一个空的
和现有的目录。
I am reviewing a very old commit. I want to see the changes a particular commit made but I want to see that in full context, i.e. I want to see whole file and the changes that person had made. The following command,
git show -w <commit-id>
is not showing me full context. Any suggestion?
git-show
comes with the following flag
-U<n>, --unified=<n>
Generate diffs with <n> lines of context instead of the usual
three. Implies -p.
See the git-show
man page for more details.
By specifying a large enough <n>
, e.g.
git show -U1000 <object>
you will get full context.
Example
Clone some repository for the sake of this example (e.g. the Git project's repo):
$ git clone https://github.com/git/git
$ cd git
Try running the command in question on some committed file (e.g. Documentation/RelNotes/2.3.0.txt
):
$ git show -U100 -- Documentation/RelNotes/2.3.0.txt
commit 1e6f5b22ad318446500fbd3b94b733eddd5b6414
Author: Junio C Hamano <gitster@pobox.com>
Date: Wed Jan 7 13:12:54 2015 -0800
Fourth batch for 2.3 cycle
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/Documentation/RelNotes/2.3.0.txt b/Documentation/RelNotes/2.3.0.txt
index 1b1dcbb..7f25bbf 100644
--- a/Documentation/RelNotes/2.3.0.txt
+++ b/Documentation/RelNotes/2.3.0.txt
@@ -1,165 +1,247 @@
Git v2.3 Release Notes
======================
Updates since v2.2
------------------
Ports
* Recent gcc toolchain on Cygwin started throwing compilation warning,
which has been squelched.
UI, Workflows & Features
* It was cumbersome to use "GIT_SSH" mechanism when the user wanted
to pass an extra set of arguments to the underlying ssh. A new
environment variable GIT_SSH_COMMAND can be used for this.
* A request to store an empty note via "git notes" meant to remove
note from the object but with --allow-empty we will store a
(surprise!) note that is empty.
* "git interpret-trailers" learned to properly handle the
"Conflicts:" block at the end.
* "git am" learned "--message-id" option to copy the message ID of
the incoming e-mail to the log message of resulting commit.
+ * "git clone --reference=<over there>" learned the "--dissociate"
+ option to go with it; it borrows objects from the reference object
+ store while cloning only to reduce network traffic and then
+ dissociates the resulting clone from the reference by performing
+ local copies of borrowed objects.
+
* "git send-email" learned "--transfer-encoding" option to force a
non-fault Content-Transfer-Encoding header (e.g. base64).
...
Sanity check
Compare the output of that command to the contents of Documentation/RelNotes/2.3.0.txt
.
$ cat Documentation/RelNotes/2.3.0.txt
Git v2.3 Release Notes
======================
Updates since v2.2
------------------
Ports
* Recent gcc toolchain on Cygwin started throwing compilation warning,
which has been squelched.
UI, Workflows & Features
* It was cumbersome to use "GIT_SSH" mechanism when the user wanted
to pass an extra set of arguments to the underlying ssh. A new
environment variable GIT_SSH_COMMAND can be used for this.
* A request to store an empty note via "git notes" meant to remove
note from the object but with --allow-empty we will store a
(surprise!) note that is empty.
* "git interpret-trailers" learned to properly handle the
"Conflicts:" block at the end.
* "git am" learned "--message-id" option to copy the message ID of
the incoming e-mail to the log message of resulting commit.
* "git clone --reference=<over there>" learned the "--dissociate"
option to go with it; it borrows objects from the reference object
store while cloning only to reduce network traffic and then
dissociates the resulting clone from the reference by performing
local copies of borrowed objects.
* "git send-email" learned "--transfer-encoding" option to force a
non-fault Content-Transfer-Encoding header (e.g. base64).
* "git send-email" normally identifies itself via X-Mailer: header in
the message it sends out. A new command line flag --no-xmailer
allows the user to squelch the header.
* "git push" into a repository with a working tree normally refuses
to modify the branch that is checked out. The command learned to
optionally do an equivalent of "git reset --hard" only when there
is no change to the working tree and the index instead, which would
be useful to "deploy" by pushing into a repository.
* "git new-workdir" (in contrib/) can be used to populate an empty
and existing directory now.
这篇关于我怎样才能得到“git show”?用完整的上下文显示差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!