Cheat Sheet速查表
跳转到主要内容

git log 速查表

本文根据 Devhints / git log 翻译。代码示例及版本范围沿用原文。

修订版本范围

git log master             # branch
git log origin/master      # branch, remote
git log v1.0.0             # tag

git log master develop

git log v2.0..master       # reachable from *master* but not *v2.0*
git log v2.0...master      # reachable from *master* and *v2.0*, but not both

参见 gitrevisions.

基本过滤器

-n, --max-count=2
    --skip=2
    --since="1 week ago"
    --until="yesterday"
    --author="Rico"
    --committer="Rico"

搜索

    --grep="Merge pull request"   # in commit messages
    -S"console.log"               # in code
    -G"foo.*"                     # in code (regex)
    --invert-grep
    --all-match                   # AND in multi --grep

限制

    --merges
    --no-merges
    --first-parent          # no stuff from merged branches
    --branches="feature/*"
    --tags="v*"
    --remotes="origin"

简化

git log -- app/file.rb          # only file
    --simplify-by-decoration    # tags and branches

排序

    --date-order
    --author-date-order
    --topo-order              # "smart" ordering
    --reverse

格式化

    --abbrev-commit
    --oneline
    --graph

自定义格式

    --pretty="format:%H"

参见: Git 日志格式速查表

另请参阅