← 返回命令列表

Linux command

git-log 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show commit history

git log

Show compact log

git log --oneline

Show graph view

git log --graph --oneline --all

Show specific file history

git log [file.txt]

Show last N commits

git log -n [5]

说明

git log shows the commit history in reverse chronological order. Each entry displays the commit hash, author, date, and message. Extensive formatting and filtering options enable customized output for any use case. The command supports filtering by author, date range, file path, and message content. Graph mode visualizes branch structure with ASCII art. Custom format strings enable scripted log processing and report generation.

参数

--oneline
Compact one-line format.
--graph
Show branch graph.
--all
Show all branches.
-n _NUM_
Limit to N commits.
--author _AUTHOR_
Filter by author.
--since _DATE_
Show commits since date.
--stat
Show changed files.
-p, --patch
Show diffs.
--format _FORMAT_
Custom format string.
--help
Display help information.

FAQ

What is the git-log command used for?

git log shows the commit history in reverse chronological order. Each entry displays the commit hash, author, date, and message. Extensive formatting and filtering options enable customized output for any use case. The command supports filtering by author, date range, file path, and message content. Graph mode visualizes branch structure with ASCII art. Custom format strings enable scripted log processing and report generation.

How do I run a basic git-log example?

Run `git log` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --oneline do in git-log?

Compact one-line format.