To view a detailed commit history in a Git repository, you can use the git log
command. This command provides a wealth of information about each commit, including the commit hash, author, date, and commit message.
Basic git log Usage
The most basic usage of git log
is simply running the command in the terminal:
git log
This will display the commit history, showing the commit hash, author, date, and commit message for each commit.
Customizing the git log Output
You can customize the output of git log
to display more detailed information about each commit. Here are some common options:
git log --oneline
: Displays a compact one-line summary of each commit.
git log --stat
: Displays the files that were changed in each commit, along with the number of additions and deletions.
git log -p
: Displays the actual changes (the "diff") introduced in each commit.
git log --author="<author_name>"
: Filters the log to show only commits made by a specific author.
git log --since="<date>"
and git log --until="<date>"
: Filters the log to show only commits made within a specific date range.
Visualizing the Commit History
To get an even more comprehensive view of the commit history, you can use the git log --graph
option. This will display the commit history in a visual, tree-like format, making it easier to understand the branching and merging of the project.
git log --graph --oneline --decorate --all
This command will show the commit history in a compact, graphical format, with branches and merges clearly visible.
By using these various git log
options, you can explore the detailed commit history of your Git repository and gain valuable insights into the development of your project.