0
0
Gitdevops~5 mins

Searching history with git log -S - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the -S option do in git log?
The -S option searches for commits that add or remove a specific string in the code. It helps find changes related to that exact text.
Click to reveal answer
intermediate
How is git log -S different from git log -G?
-S searches for changes in the number of occurrences of a string, while -G searches for commits that match a regular expression pattern in the diff.
Click to reveal answer
beginner
Write a command to find commits that added or removed the word 'bugfix' in the project history.
git log -S'bugfix'
Click to reveal answer
intermediate
Can git log -S search for changes in binary files?
No, git log -S works only with text changes. It cannot search inside binary files.
Click to reveal answer
beginner
Why might git log -S be useful when debugging?
It helps find exactly when a specific piece of code was added or removed, making it easier to track down when a bug was introduced or fixed.
Click to reveal answer
What does git log -S'functionName' do?
AShows commits that contain 'functionName' anywhere
BShows commits that deleted 'functionName' only
CShows commits that changed the file named 'functionName'
DShows commits that added or removed 'functionName'
Which option would you use to search commits by a regular expression pattern?
A-p
B-S
C-G
D-a
If you want to find when a variable name was changed, which command helps best?
Agit log -S'variableName'
Bgit log --oneline
Cgit status
Dgit diff
Does git log -S show commits that only mention the string in commit messages?
AYes, it searches commit messages
BNo, it searches code changes only
CYes, but only for merge commits
DNo, it searches file names only
What is a practical use of git log -S?
ATo find when a specific code line was added or removed
BTo list all branches
CTo merge two branches
DTo clone a repository
Explain how git log -S helps you find when a specific piece of code was added or removed.
Think about how you find when a word first appeared or disappeared in your project.
You got /3 concepts.
    Describe the difference between git log -S and git log -G.
    One looks for exact string changes, the other for pattern matches.
    You got /3 concepts.