0
0
Gitdevops~15 mins

git log formatting options - Mini Project: Build & Apply

Choose your learning style9 modes available
Explore git log formatting options
📖 Scenario: You are working on a project with a Git repository. You want to see the commit history in a clear and customized way to understand changes better.
🎯 Goal: Learn how to use git log with formatting options to display commit history with specific details.
📋 What You'll Learn
Use git log command
Format commit logs with --pretty=format: option
Display commit hash, author name, date, and commit message in a custom format
💡 Why This Matters
🌍 Real World
Developers often need to review commit history clearly to understand changes and authorship.
💼 Career
Knowing how to customize git log output is useful for code reviews, debugging, and reporting in software development jobs.
Progress0 / 4 steps
1
Initialize a Git repository and make commits
Create a new Git repository and make two commits with messages "First commit" and "Second commit".
Git
Need a hint?

Use git init to start a repo, then create a file and commit twice with the exact messages.

2
Set a custom format string for git log
Create a variable called format_string and set it to "%h - %an, %ar : %s" to show short commit hash, author name, relative date, and commit message.
Git
Need a hint?

Assign the exact string "%h - %an, %ar : %s" to format_string.

3
Use git log with the custom format string
Use the command git log --pretty=format:"$format_string" to display the commit history with the custom format.
Git
Need a hint?

Use git log --pretty=format:"$format_string" exactly to show commits.

4
Display the formatted git log output
Run the command to display the commit history with the custom format and observe the output.
Git
Need a hint?

The output should show two lines with short hashes, author names, relative dates, and commit messages.