0
0
Gitdevops~20 mins

git log formatting options - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Log Format Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1: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"
Acommit abc1234 - Initial commit
BInitial commit - abc1234
Cabc1234 - Initial commit
Dabc1234 Initial commit
Attempts:
2 left
💡 Hint
The format string uses %h for short hash and %s for subject.
🧠 Conceptual
intermediate
1:30remaining
Understanding git log placeholders
Which placeholder in git log --pretty=format: shows the author date in ISO 8601 format?
A%ai
B%ad
C%cd
D%ci
Attempts:
2 left
💡 Hint
Look for the placeholder ending with 'i' for ISO format.
Troubleshoot
advanced
1: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
Agit log does not support --pretty=format option
BMissing closing double quote for the format string
CThe commit message %s is not allowed here
DInvalid placeholder %h
Attempts:
2 left
💡 Hint
Check if the quotes are balanced.
Best Practice
advanced
2: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?
A%h %an %ai
B%h %an %ad
C%H %an %ai
D%h %ae %cd
Attempts:
2 left
💡 Hint
Use short hash and author name with ISO date.
🔀 Workflow
expert
2: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?
Agit config --global alias.summary "log --pretty=format:%h %an %s"
Bgit config --global alias.summary "log --pretty=format:\"%h %an %s\""
Cgit config --global alias.summary "log --pretty=format:'%h %an %s'"
Dgit config --global alias.summary 'log --pretty=format:"%h %an %s"'
Attempts:
2 left
💡 Hint
Remember to properly quote the format string inside the alias.