Inspecting the commit log of a repository¶
Retrieve the commit log of a repository in an easy-to-parse format.
View the entire log¶
Calling Log
without any options will retrieve the entire repository log from the current branch. A default formatting of --pretty=oneline --no-decorate --no-color
is applied by gitz
during log retrieval:
Printing the Raw
output from this command:
99cb396148cff7db435cebb9a8ea95a11b5658e1 fix: input string parsing error
e8b67f90c613340fd61392fda03181d86a7febbe ci: extend existing build workflow
c90e819baa6ddc212811924c51256e65f53d4c32 docs: create mkdocs documentation
1635f10b81a810833b163793e6ef902d52a89789 feat: add first feature to library
a09348464773e99dbc94a5494b5b83b253c18019 initialized repository
By default, gitz
parses the log into a structured output accessible through the Commits
property. This structure contains each commit's associated Hash
, Abbreviated Hash
, and Message
.
Return only raw output from the log¶
Use the WithRawOnly
option to skip parsing of the log into the structured Commits
property, improving performance. Perfect if you want to carry out any custom processing.
Printing the Commits
property should now be an empty slice:
View the log from a point in time¶
When retrieving the log history, the WithRef
option provides a starting point other than HEAD (most recent commit). A reference can be a Commit Hash
, Branch Name
, or Tag
. Output from this option will be a shorter, fine-tuned log.
View a snapshot of the log¶
The WithRefRange
option provides a start and end point for retrieving a snapshot of the log history between two points in time. A reference can be a Commit Hash
, Branch Name
, or Tag
. Output from this option will be a shorter, fine-tuned log.
View the log of any files or folders¶
Fine-tune the log history further with the WithPaths
option. Providing a set of relative paths to any files and folders within the repository will include only commits related to their history.
Printing the Raw
output from this command:
d611a22c1a009bd74bc2c691b331b9df38828dae fix: typos in file content
9b342465255d1a8ec4f5517eef6049e5bcc8fb45 feat: a brand new feature
Resolving explicit file paths¶
Querying the log with explicit paths isn't supported and will return no history. Converting to a relative one can be achieved with the ToRelativePath
helper, as it resolves paths against the root working directory of the current repository.
Cherry-picking a section of the log¶
Cherry-pick a section of the log by skipping and taking a set number of entries using the respective WithSkip
and WithTake
options. If combined, skipping has a higher order of precedence:
Printing the Raw
output from this command:
9967e3c6196422a6a97afa4b6fca9f609bb5490b fix: filtering on unsupported prefixes
1b1f4a725cfe44d5c9bd992be59f1130ed9d9911 docs: create docs using material mkdocs
Filtering the log with pattern matching¶
Filter the commit log to only contain entries that match any set of patterns (regular expressions) using the WithGrep
option:
Printing the Raw
output from this command, with matches highlighted for reference only:
2d68a506fe7d5148db0a10ea143752991a65c26d docs: document pattern matching option
5bfd532328ed2e9ea6d3062eb3a331f42468a7e3 feat: filter log with pattern matching
Filter entries that do not match¶
Combining the WithInvertGrep
and WithGrep
options will inverse pattern matching and filter on log entries that do not contain any of the provided patterns.
Filter entries that match all patterns¶
Pattern matching uses or
semantics by default, matching on log entries that satisfy any of the defined patterns. You can change this behavior to match against all patterns using and
semantics with the WithMatchAll
option.