📜  git log show summary - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:00:55.970000             🧑  作者: Mango

Git Log Show Summary for Shell/Bash

As a programmer, you may already know the importance of keeping track of changes in your codebase. Git is one of the most popular version control systems used in the industry, and it can help you manage your project effectively. In this tutorial, you will learn how to use the git log command to show a summary of commits in your repository using Shell/Bash.

Prerequisites

Before we dive into the specifics of the git log command, make sure you have Git installed on your system. If you are not sure, you can run the following command in your terminal to check:

git --version
Getting Started

Assuming you have Git installed, navigate to your repository directory in your terminal.

To see a summary of your commits in git log:

git log --pretty=format:"%h %s"

This will show the commit hash (abbreviated) and the commit message in a clean and concise format.

If you want to limit the number of commits shown, add the --max-count option followed by the number of commits you want to see. For example, to see the last 5 commits, run:

git log --pretty=format:"%h %s" --max-count=5
Additional Options

--author

You can use --author option to filter commits by author. For example, to see the commits made by a specific author, run:

git log --author="John Doe" --pretty=format:"%h %s"

--since and --until

You can use --since and --until options to limit commits by date. For example, to see the commits made between two dates, run:

git log --since="2021-01-01" --until="2021-12-31" --pretty=format:"%h %s"

--grep

You can use --grep option to filter commits by commit message. For example, to see the commits that contain the word "bug", run:

git log --grep="bug" --pretty=format:"%h %s"

--oneline

You can use --oneline option to show abbreviated commit IDs and commit messages in a single line. For example, to see the last 5 commits in one line, run:

git log --pretty=format:"%h %s" --max-count=5 --oneline

--color

You can use --color option to show git output in color. For example, to see the colored git log output, run:

git log --pretty=format:"%h %s" --color
Conclusion

In this tutorial, you learned how to use the git log command in Shell/Bash to show a summary of commits in your repository. You also learned how to use some additional options to filter and customize the output according to your needs. The git log command is an essential tool for managing your codebase and tracking changes, so make sure to use it regularly in your workflow.