代码之家  ›  专栏  ›  技术社区  ›  Snowcrash

“git show”单独做什么?

  •  5
  • Snowcrash  · 技术社区  · 7 年前

    如果我使用 git show 在git repo中,它单独显示了一堆信息,如提交、差异等。

    本页(页) https://git-scm.com/docs/git-show 只是说:

    Shows one or more objects (blobs, trees, tags and commits).

    我想这是最新的承诺。还有一些差异(文档页面中没有提到)。

    但它到底在显示什么呢?

    这是完整的,不可理解的,输出…

    $ git show
    commit <sha1 A> (HEAD -> A)
    Merge: <sha1 B> <sha1 C>
    Author: Snowcrash <my@email>
    Date:   Sat Jul 14 14:56:02 2018 -0700
    
        with both files
    
    diff --cc 1
    index <sha1 D>,<sha1 E>..<sha1 F>
    --- a/1
    +++ b/1
    @@@ -1,5 -1,6 +1,12 @@@
      1
    
    ++<<<<<<< HEAD
     +A
     +B
     +C
    ++=======
    + C
    + D
    + E
    +
    ++>>>>>>> master
    diff --cc 2
    index 0000000,0000000..<sha1 G>
    new file mode 100644
    --- /dev/null
    +++ b/2
    @@@ -1,0 -1,0 +1,1 @@@
    ++2
    
    2 回复  |  直到 7 年前
        1
  •  6
  •   Rory O'Kane Erce    7 年前

    AS emlai wrote , git show 描述 HEAD 默认情况下提交。至于 什么 它显示了 提交 git-show manual page 描述输出:

    对于提交,它显示日志消息和文本差异。它还以由 git diff-tree --cc .

    至少对于非合并提交,此输出与 git log --cc HEAD~..HEAD . 这个 --cc 标志导致显示差异。

        2
  •  3
  •   Emil Laine    7 年前

    git show 相当于 git show HEAD ,即当前分支中的最新提交( more info )

    来源: https://github.com/git/git/commit/9f5258cbb8f8ed2bf86b0078f178a26adc572eb9