log
The git log
command is used to display the commit history of a Git repository. It provides detailed information about each commit, including the commit hash, author, date, and commit message. This command is highly customizable, allowing you to filter and format the output in various ways.
Detailed Explanation
Basic Usage: By default,
git log
shows the commit history in reverse chronological order (most recent commits first).Formatting Options: You can customize the output format using various options, such as
--pretty
,--oneline
, and--graph
.Filtering Options: You can filter the commit history based on criteria like author, date, and commit message using options like
--author
,--since
,--until
, and--grep
.Limiting Output: You can limit the number of commits displayed using the
-n
option, wheren
is the number of commits to show.
Examples
Basic Log:
git logThis command displays the commit history with detailed information for each commit.
One-line Log:
git log --onelineThis command displays the commit history with each commit on a single line, showing the commit hash and message.
Graphical Log:
git log --graph --oneline --allThis command displays the commit history as a graph, with each commit on a single line, including all branches.