DEV Community

Lam
Lam

Posted on

1 1

Git Log Cheat Sheet

Also see

Custom formats

    --pretty="format:%H"
Enter fullscreen mode Exit fullscreen mode

Formatting

    --abbrev-commit
    --oneline
    --graph
Enter fullscreen mode Exit fullscreen mode

Ordering

    --date-order
    --author-date-order
    --topo-order              # "smart" ordering
    --reverse
Enter fullscreen mode Exit fullscreen mode

Simplification

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

Limiting

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

Search

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

Basic filters

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

Revision ranges

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
Enter fullscreen mode Exit fullscreen mode

See gitrevisions.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay