git-log/show

Git log and got show
review a repository's history are git log and git show
Git log
git log:display information about the existing commits
默认情况下,该命令会显示仓库中每个 commit 的:
  • SHA

  • 作者

  • 日期

  • 消息

    SHA: SHA 基本上就是每次提交的 ID 号码,是由 40 个字符(0-9 和 a-f)组成的字符串,根据 Git 中的文件内容或目录结构计算而成。“SHA”是“SHA散列”的简写。

    git uses the less program as its pager,
    1.press either the J key or the down arrow to scroll down one line at a time.
    2. to scroll up press the K key or the up arrow.
    3.When the colon(冒号) changes to the word end,you’ve reached the very last commit.
    4. to get out of the pager just press the Q key.

git log --oneline
$ git log --oneline
用来更改仓库信息的显示方式
此命令:
  • 每行显示一个 commit

  • 显示 commit 的 SHA 的前 7 个字符

  • 显示 commit 的消息

    q 键使终端返回命令提示符

git log --stat
显示 commit 中更改的文件以及添加或删除的行数
此命令会:
  • 显示被修改的文件

  • 显示添加/删除的行数

  • 显示一个摘要,其中包含修改/删除的总文件数和总行数

git log -p(patch)
git can keep track of renamed files.
带注释的 git log -p 输出

我们通过上述图片快速总结下 git log -p 的输出:

  • 🔵 - 正在显示的文件
  • 🔶 - 文件第一版的哈希值和第二版的哈希值
    通常不重要,因此可以忽略
  • ❤️ - 文件的旧版本和当前版本
  • 🔍 - 添加的行所在的位置以及添加了多少行
    • -15,83 表示旧版本(用 - 表示)从第 15 行开始,显示了 83 行
    • +15,85 表示当前版本(用 + 表示)从第 15 行开始,现在变成了 85 行…这 85 行显示在下方
  • ✏️ - 在 commit 中实际进行的更改
    • 用红色标示并以减号 (-) 开头的行是位于文件原始版本中,但是被 commit 删除的行
    • 用绿色标示并以加号 (+) 开头的行是 commit 新加的行
git log -p -w

-w

  • –ignore-all-space
    ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.

  • –ignore-blank-lines
    Ignore changes whose lines are all blank.

git log --pretty

这个选项可以使用不同于默认格式的方式展示提交历史.这个选项有一些内建的子选项供你使用。 比如 oneline 会将每个提交放在一行显示,在浏览大量的提交时非常有用。 另外还有 short,full 和 fuller 选项,它们展示信息的格式基本一致,但是详尽程度不一:

$ git log --pretty=oneline
ca82a6dff817ec66f44342007202690a93763949 changed the version number
085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test
a11bef06a3f659402fe7563abf99ad00de2209e6 first commit

最有意思的是 format ,可以定制记录的显示格式。 这样的输出对后期提取分析格外有用——因为你知道输出的格式不会随着 Git 的更新而发生改变:

$ git log --pretty=format:"%h - %an, %ar : %s"
ca82a6d - Scott Chacon, 6 years ago : changed the version number
085bb3b - Scott Chacon, 6 years ago : removed unnecessary test
a11bef0 - Scott Chacon, 6 years ago : first commit

在这里插入图片描述

显示特定commit的详情
  • 向 git log 提供你要查看的 commit 的 SHA
  • 使用 git show 命令

git show:display information about the given commit
git show 命令将仅显示一个 commit。git show 命令的输出和 git log -p 命令的完全一样。

git show 可以与我们了解过的大部分其他选项一起使用:

  • –stat - 显示更改了多少文件,以及添加/删除的行数

  • -p 或 --patch - 显示默认补丁信息,但是如果使用了 --stat,将不显示补丁信息,因此传入 -p 以再次添加该信息

  • -w - 忽略空格变化

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
-- Detected 64-bit platform -- UNIX: Configuring uninstall target -- UNIX: Created uninstall target -- UNIX: Using default system linker -- UNIX: Detected compiler: /usr/bin/cc -- Clang: Minimum version required is 7.0.0, found 14.0.0 - ok! -- Using mysql-config: /usr/bin/mysql_config -- Found MySQL library: /usr/lib/x86_64-linux-gnu/libmysqlclient.so -- Found MySQL headers: /usr/include/mysql -- Found MySQL executable: /usr/bin/mysql fatal: 不是 git 仓库(或者任何父目录):.git CMake Error at cmake/genrev.cmake:116 (string): string sub-command REGEX, mode MATCH needs at least 5 arguments total to command. Call Stack (most recent call first): CMakeLists.txt:83 (include) * TrinityCore revision : + (+ branch) * TrinityCore buildtype : RelWithDebInfo * Install core to : /home/wow/server3.5.5 * Install configs to : /home/wow/server/etc * Build world/auth : Yes (default) * Build with scripts : Yes (static) * Build map/vmap tools : Yes (default) * Build unit tests : No (default) * Build core w/PCH : Yes (default) * Build scripts w/PCH : Yes (default) * Show compile-warnings : No (default) * Use coreside debug : No (default) * Show source tree : Yes (hierarchical) * Use GIT revision hash : Yes (default) -- Found OpenSSL library: /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so -- Found OpenSSL headers: /usr/include CMake Error at cmake/macros/FindOpenSSL.cmake:579 (message): TrinityCore needs OpenSSL version 1.0 but found too new version 3.0.2. TrinityCore needs OpenSSL 1.0.x or 1.1.x to work properly. If you still have problems please install OpenSSL 1.0.x if you still have problems search on forum for TCE00022 Call Stack (most recent call first): dep/openssl/CMakeLists.txt:16 (find_package) -- Configuring incomplete, errors occurred! See also "/home/wow/TrinityCore/TrinityCore-TDB335.22061/build/CMakeFiles/CMakeOutput.log". See also "/home/wow/TrinityCore/TrinityCore-TDB335.22061/build/CMakeFiles/CMakeError.log".
05-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值