linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Chapters
  • How it works
  • Lessons
  • Knowledge base
  • Interview prep
home/git/kb/Everyday workflow/log

kb/workflow ── Everyday workflow ── beginner

git log

Traverses the commit graph and prints each commit. By default it starts at HEAD and follows parents. A dozen flags cover 95% of history-browsing scenarios.

view as markdownaka: git-log

git log is the primary command for reading history. Technically it traverses the commit graph via git rev-list and prints each commit's description via git cat-file.

Basic invocation

bash
git log

Prints each commit: SHA, author, date, message. Uses a pager (less) by default; press q to exit.

Most useful forms

bash
git log --oneline                # one line per commit
git log --oneline -10            # last 10
git log --oneline --graph --all  # tree of all branches
git log --stat                   # + summary of changed files
git log -p                       # + full diff of each commit
git log --follow file.txt        # history of one file, tracking renames

The most useful everyday form is --oneline --graph --all --decorate. Many people set it up as an alias:

bash
git config --global alias.lg "log --oneline --graph --all --decorate"
git lg

Filters

bash
git log --since="2 weeks ago"
git log --until=2026-01-01
git log --author=Linus
git log --grep="fix.*memory"      # regex on commit messages
git log -S "deprecated"           # commits where this word appeared or disappeared
git log -- src/api.ts             # only commits that touched this path
git log main..feature             # commits in feature that are not in main

-S (pickaxe) is a particularly powerful filter for finding "when was this function removed" or "when did this field first appear".

Output formats

bash
git log --pretty=format:"%h %an %s"   # short SHA, author, subject
git log --pretty=fuller                # both dates: author and committer
git log --format=%H -n 1               # full SHA of the last commit only

--pretty=fuller is especially useful after a rebase to see the divergence between author date and committer date.

Pitfalls

  • git log file.txt without --follow loses history at renames.
  • git log --graph on a large history can become unreadable. Filter by branch or path in that case.
  • In scripts, prefer git rev-list (plumbing) over git log. Its output format is stable.

§ команды

bash
git log --oneline --graph --all

Commit tree of all branches, one line each

bash
git log -p -- file.txt

History of one file with all diffs

bash
git log main..feature

Commits in feature that are not yet in main

bash
git log -S 'deprecated'

Find the commit where a word first appeared or disappeared

§ см. также

  • statusgit statusShows the difference between three Git zones: what is modified in the working tree, what is staged in the index, and which branch is active. The safest command in Git: it changes nothing and you can run it as often as you like.
  • commit-cmdgit commitCaptures what is in the index as a new commit object and moves the current branch to that commit. Without arguments it opens an editor for the message; the most common form uses `-m`.
  • rev-parsegit rev-parseA plumbing command that translates human-readable ref names (HEAD, main~2, v1.0, :/typo) into full SHAs. Used by all porcelain commands under the hood, and convenient in scripts.
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies