This command is useful for quickly viewing a specific number of recent commits by limiting the log output to the provided count.
The -<number>
flag works as a shorthand for --max-count=<number>
, where <number>
specifies how many commit entries to display; alternatively, you can write it as -n <number>
for the same result.
Variations include git log -n <number>
or git log --max-count=<number>
for explicit flags, combining with --oneline
to condense each commit to a single line, adding filters like --since=\"2 weeks ago\"
or --author=\"Name\"
, or using git show <commit>
to inspect a particular commit in detail.
Examples:
git log -5
git log -n 10 --oneline
git log --max-count=3 --since=\"1 week ago\"