Challenge - 5 Problems
Git Log Format Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of git log with custom format
What is the output of the following command if the latest commit hash is
abc1234 and the commit message is Initial commit?Git
git log -1 --pretty=format:"%h - %s"
Attempts:
2 left
💡 Hint
The format string uses %h for short hash and %s for subject.
✗ Incorrect
The --pretty=format:"%h - %s" option prints the short commit hash followed by a dash and the commit message subject.
🧠 Conceptual
intermediate1:30remaining
Understanding git log placeholders
Which placeholder in
git log --pretty=format: shows the author date in ISO 8601 format?Attempts:
2 left
💡 Hint
Look for the placeholder ending with 'i' for ISO format.
✗ Incorrect
%ai shows the author date in strict ISO 8601 format. %ad shows author date but in a format that can be customized.
❓ Troubleshoot
advanced1:30remaining
Troubleshooting git log format syntax error
You run
git log --pretty=format:"%h %s and get a syntax error. What is the cause?Git
git log --pretty=format:"%h %s
Attempts:
2 left
💡 Hint
Check if the quotes are balanced.
✗ Incorrect
The command is missing the closing double quote, causing the shell or git to report a syntax error.
✅ Best Practice
advanced2:00remaining
Best practice for showing commit date and author
Which git log format string best shows the commit hash, author name, and commit date in ISO format on one line?
Attempts:
2 left
💡 Hint
Use short hash and author name with ISO date.
✗ Incorrect
%h is short hash, %an is author name, and %ai is author date in ISO 8601 format, making option A the best choice.
🔀 Workflow
expert2:30remaining
Creating a custom git log alias with formatting
You want to create a git alias named
summary that shows each commit's short hash, author, and subject in one line. Which command correctly sets this alias?Attempts:
2 left
💡 Hint
Remember to properly quote the format string inside the alias.
✗ Incorrect
Option D correctly uses single quotes around the entire argument and double quotes inside for the format string, avoiding shell parsing issues.