git log -S'fixBug' do?Consider the command git log -S'fixBug'. What is the output or effect of running this command in a git repository?
git log -S'fixBug'
Think about what the -S option searches for in the commit history.
The -S option in git log searches for commits where the specified string was added or removed in the code changes, not just in messages or filenames.
calculateSum?You want to find commits where the function calculateSum was added or removed in your code. Which git command is best suited for this?
Remember, -S searches code changes, while --grep searches commit messages.
git log -S'calculateSum' searches commits that added or removed the string 'calculateSum' in the code, which is what you want.
git log -S'init' show no commits even though the string exists in the code?You run git log -S'init' but it returns no commits, even though the string 'init' is present in your current code files. What is the most likely reason?
Think about what -S actually searches for in commits.
-S finds commits where the string was added or removed. If 'init' was never changed but always present, no commits will match.
git log -S and git log -G?Both git log -S and git log -G search commit history. What is the key difference between them?
Consider how -S and -G treat the search string.
-S looks for commits where the count of a string changes (added or removed). -G looks for commits where the diff matches a regex pattern.
TODO using git log -S?You want to find the very first commit in your repository history that introduced the string TODO. Which sequence of commands or options will help you achieve this?
Think about how to reverse the order and limit results to find the first commit.
Using --all searches all refs, --reverse shows commits from oldest to newest, and --max-count=1 limits output to the first match, which is the first commit that introduced 'TODO'.