To view the Git commit history
, you can use the following commands:
1. View a summarized log:
The most basic way to view the commit history is by using the `git log` command. It displays the commit history in reverse chronological order, with the most recent commit appearing first. By default, it provides information such as the commit hash, author, date, and commit message.
Press the spacebar to scroll through the log, and press 'q' to exit the log view.
2. View a summarized log with graph:
To get a more visually informative representation of the commit history, you can use the `git log`
command with the `--graph`
option. This displays the commit history as a text-based graph, showing the branches, merges, and commits.
The graph view provides a clearer picture of how branches and commits are related.
3. View a summarized log with one-line commit messages:
If you prefer a condensed view of the commit history, you can use the `--oneline`
option with `git log`
. This displays each commit on a single line, showing only the commit hash and the first line of the commit message.
This format is useful when you want a quick overview of the commit history.
4. View a detailed log:
If you want to see more detailed information about each commit, you can use the `--stat`
option with `git log`
. This displays the summary of changes made in each commit, showing the modified files and the number of insertions and deletions.
This is helpful when you need a more comprehensive understanding of the changes made in each commit.
5. Limit the number of commits:
By default, `git log`
shows the entire commit history. However, you can limit the number of commits displayed by using the `-n`
option, followed by the desired number of commits.
This command will show only the last five commits.
6. Filter the commit history:
You can filter the commit history based on various criteria, such as the author, specific files, or a date range. Some examples include:
- Filter by author:
- Filter by specific file:
- Filter by date range:
git log --author="John Doe"
git log --since="2023-01-01" --until="2023-06-30"
These filters allow you to narrow down the commit history based on your specific requirements.
These commands provide different ways to view the Git commit history, allowing you to examine the changes made, the commit relationships, and the associated metadata. Choose the option that best suits your needs for understanding and analyzing the commit history.