Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Viewing commit history

Header Image

Ahoy there mateys! Welcome aboard our ship of version control systems. Today, we’ll be setting sail on a journey to explore the Git command that allows us to view the history of commits in the repository. This feature is especially useful when you want to see the changes made to the codebase and who made them. So, hoist the anchor and let’s set sail!

Git log

To view the commit history, we’ll use the git log command. This command displays a list of all commits in reverse chronological order, with the most recent commit appearing first. The log includes information such as the commit hash, author, date, and commit message.

To view the commit history, open your terminal and navigate to the repository directory. Then, run the following command:

git log

This will display the commit history in your terminal window. You’ll see each commit’s hash, author, date, and message. If you want to see more detailed information about each commit, you can use various options with the git log command.

Options for git log

  • -p: Display the patch that each commit introduced.
  • --stat: Display the number of lines added and removed in each commit.
  • --author: Limit the results to commits made by a specific author.
  • --since: Limit the results to commits made after a specific date.
  • --until: Limit the results to commits made before a specific date.

Here’s an example of using the -p option to view the patch introduced by each commit:

git log -p

This will display the commit history along with the patch introduced by each commit. You can scroll through the patches to see exactly what changes were made to the codebase.

Conclusion

Congratulations, me hearties! You’ve learned how to view the history of commits in the repository using the git log command. By using various options with the git log command, you can get more detailed information about each commit. This feature is essential when you need to understand the changes made to the codebase and who made them. Keep learning and exploring Git, and who knows, you may discover a hidden treasure trove of knowledge. Until then, fair winds and following seas, mateys!