Linux command
git-rev-list 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List all commits
git rev-list HEAD
Count commits
git rev-list --count HEAD
List commits in range
git rev-list [commit1]..[commit2]
List with date order
git rev-list --date-order HEAD
List reachable from multiple
git rev-list [branch1] [branch2] --not [main]
First parent only
git rev-list --first-parent HEAD
说明
git rev-list lists commit objects in reverse chronological order. It is a low-level plumbing command used for enumerating reachable commits and objects, forming the basis for many higher-level Git commands. Common uses include counting commits, finding merge bases, and building commit ranges for other tools.
参数
- --count
- Show count only.
- --max-count _n_
- Limit output.
- --since _date_
- Commits after date.
- --until _date_
- Commits before date.
- --author _pattern_
- Filter by author.
- --first-parent
- Follow first parent only.
- --ancestry-path
- Show ancestry path.
- --objects
- Include all referenced object IDs (trees, blobs), useful for packing.
- --all
- Walk every ref under `refs/`, plus HEAD.
- --branches=_pattern_, --tags=_pattern_, --remotes=_pattern_
- Walk matching refs under the respective namespace.
- --no-merges, --merges
- Exclude or include merge commits (equivalent to `--max-parents=1` / `--min-parents=2`).
- --min-parents _n_, --max-parents _n_
- Filter commits by parent count.
- --reverse
- Print commits in chronological order.
- --topo-order, --date-order
- Order output topologically or by commit date.
- --left-right
- With `A...B`, mark commits as `<` (from A) or `>` (from B).
- --boundary
- Include excluded boundary commits, prefixed with `-`.
- --grep _pattern_, --committer _pattern_
- Filter by commit message / committer identity, in addition to --author.
FAQ
What is the git-rev-list command used for?
git rev-list lists commit objects in reverse chronological order. It is a low-level plumbing command used for enumerating reachable commits and objects, forming the basis for many higher-level Git commands. Common uses include counting commits, finding merge bases, and building commit ranges for other tools.
How do I run a basic git-rev-list example?
Run `git rev-list HEAD` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --count do in git-rev-list?
Show count only.