5

私は非常に古いコミットを見直しています。特定のコミットが行った変更を確認したいが、それを完全なコンテキストで確認したい、つまり、ファイル全体とその人が行った変更を確認したい。次のコマンド、

git show -w <commit-id>

完全なコンテキストが表示されません。なにか提案を?

4

2 に答える 2

7

git-show次のフラグが付属しています

-U<n>, --unified=<n>
    Generate diffs with <n> lines of context instead of the usual
    three. Implies -p.

詳細については、git-showman ページを参照してください。十分な大きさを指定することにより<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
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).
...

サニティーチェック

そのコマンドの出力を の内容と比較します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.
于 2015-01-09T10:09:53.573 に答える
1

この投稿から、特定のコミットを調べたときに、次のようにファイルが表示されます。

  git show REVISION:path/to/file

編集:以下のコメントに基づいて、上記がOPが求めていたものと完全に一致しない可能性があることが強調されています。

各行の変更と作成者とともに特定のバージョンのファイルを取得するには、代わりに次を使用する必要があります。

  git blame REVISION path/to/file
于 2015-01-09T11:31:34.647 に答える