How to view the commit history of a Git repository?

To view the commit history of a Git repository, you can use the git log command. Here are the steps:

  1. Open the terminal or command prompt.
  2. Navigate to the directory where the Git repository is located using the cd command.
  3. Run the following command to view the commit history:
git log

This command will display a list of commits in reverse chronological order, showing information such as the commit hash, author, date, and commit message.

You can use the following options with git log to customize the output:

  • --oneline: Displays each commit in a single line format.
  • --author=[author name]: Filters the commits based on the author's name.
  • --after=[date], --before=[date]: Filters the commits based on the specified date range.
  • --grep=[pattern]: Filters the commits based on a specified pattern in the commit message.

For example, to view the commit history in a single line format, you can use the command:

git log --oneline

Remember to replace [author name], [date], or [pattern] with the actual value you want to filter by.