Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does the command git log do?
It shows the list of commits made in the current branch, displaying details like commit ID, author, date, and message.
Click to reveal answer
beginner
How can you view a simplified one-line summary of each commit using git log?
Use git log --oneline to see each commit as a single line with a short commit ID and the commit message.
Click to reveal answer
intermediate
What option would you add to git log to see the changes made in each commit?
Add -p to git log to show the patch (diff) introduced by each commit.
Click to reveal answer
beginner
How do you limit the number of commits shown by git log?
Use git log -n <number> to show only the last <number> commits. For example, git log -n 3 shows the last 3 commits.
Click to reveal answer
intermediate
What does the --graph option do when used with git log?
It shows a text-based graph of the branch structure and commit history, helping visualize merges and branches.
Click to reveal answer
Which command shows a simple one-line summary of each commit?
Agit log -p
Bgit log --oneline
Cgit status
Dgit diff
✗ Incorrect
git log --oneline shows each commit in a short, one-line format.
How do you see the detailed changes introduced by each commit?
Agit log -p
Bgit log --oneline
Cgit show
Dgit diff HEAD
✗ Incorrect
git log -p shows the patch (diff) for each commit in the log.
What does git log -n 5 do?
AShows commits with 5 files changed
BShows commits from 5 days ago
CShows commits with 5 authors
DShows the last 5 commits
✗ Incorrect
The -n option limits the number of commits shown to the specified number.
Which option adds a visual graph of branches to the commit history?
A--stat
B--oneline
C--graph
D-p
✗ Incorrect
--graph draws a text-based graph showing branch and merge history.
What information is NOT shown by default in git log?
AFiles changed in the commit
BAuthor name
CDate of commit
DCommit message
✗ Incorrect
By default, git log does not show files changed; use -p or --stat for that.
Explain how to use git log to view a simple list of recent commits with short IDs and messages.
Think about a command that makes the log easier to read quickly.
You got /4 concepts.
Describe how to see the actual changes made in each commit using git commands.
Look for an option that shows differences inside the log.
You got /4 concepts.
Practice
(1/5)
1. What does the git log command do in a Git repository?
easy
A. Deletes the last commit from the repository
B. Shows the history of commits made in the repository
C. Creates a new branch in the repository
D. Displays the current status of files in the repository
Solution
Step 1: Understand the purpose of git log
The git log command is used to view the commit history in a Git repository.
Step 2: Compare with other Git commands
Other commands like git status show file status, and git branch manages branches, but git log specifically shows commits.
Final Answer:
Shows the history of commits made in the repository -> Option B
Quick Check:
git log = commit history [OK]
Hint: Remember: log means history or record [OK]
Common Mistakes:
Confusing git log with git status
Thinking git log deletes commits
Mixing git log with branch creation
2. Which of the following is the correct command to show a simplified one-line summary of each commit in Git?
easy
A. git log --oneline
B. git log --summary
C. git log --details
D. git log --short
Solution
Step 1: Identify the option for one-line commit summary
The --oneline option condenses each commit to a single line showing the commit hash and message.
Step 2: Verify other options
Options like --summary, --details, and --short are not valid git log options for this purpose.
Final Answer:
git log --oneline -> Option A
Quick Check:
--oneline = short commit list [OK]
Hint: Use --oneline for brief commit history [OK]
Common Mistakes:
Using non-existent options like --summary
Confusing --oneline with --short
Forgetting the double dash before options
3. Given the command git log -2 --oneline, what will be the output?
medium
A. Shows the last two commits in a detailed multi-line format
B. Shows all commits except the last two
C. Shows the last two commits each summarized in one line
D. Shows the first two commits in the repository
Solution
Step 1: Understand the -2 option
The -2 option limits the output to the last two commits only.
Step 2: Understand the --oneline option
The --oneline option shows each commit in a single line summary.
Final Answer:
Shows the last two commits each summarized in one line -> Option C
Quick Check:
-2 + --oneline = last two commits short [OK]
Hint: Combine -n with --oneline for short recent commits [OK]
Common Mistakes:
Thinking -2 shows first two commits
Expecting detailed multi-line output with --oneline
Confusing exclusion of commits with limiting output
4. You ran git log --oneline -p but got an error. What is the likely cause?
medium
A. The options --oneline and -p cannot be used together
B. You need to specify a branch name with the command
C. You must run git fetch before using git log
D. The repository has no commits yet
Solution
Step 1: Understand the options --oneline and -p
--oneline shows a brief summary, while -p shows patch (diff) details.
Step 2: Check compatibility of options
These two options conflict because one shows a short summary and the other shows detailed changes, so Git throws an error.
Final Answer:
The options --oneline and -p cannot be used together -> Option A
Quick Check:
--oneline + -p conflict = error [OK]
Hint: Avoid combining --oneline with -p; they conflict [OK]
Common Mistakes:
Assuming branch name is required for git log
Thinking git fetch fixes git log errors
Ignoring that empty repo causes no output, not error
5. You want to see the commit history with each commit showing the author, date, and a one-line message, all in a compact format. Which command should you use?
hard
A. git log --graph --decorate
B. git log --oneline --author-date-order
C. git log -p --stat
D. git log --pretty=format:"%h - %an, %ar : %s"
Solution
Step 1: Understand the requirement for custom format
You want author, date, and message in one line, so a custom format with --pretty=format: is needed.
Step 2: Analyze the format string
%h is short commit hash, %an is author name, %ar is relative date, and %s is commit message. This matches the requirement.
Step 3: Check other options
--oneline --author-date-order does not show author or date explicitly. -p --stat shows diffs and stats, not compact. --graph --decorate shows branch graph and refs, not author/date/message in one line.