How to find a Git commit where some code was deleted?

I added some lines of code to the repo and committed it. Then the number of commits later than these lines was deleted.

I have a commit hash when the lines that are added, and a hash of the subsequent commit that deleted them. How can I find the exact commit where they were deleted?

+4
source share
2 answers

The options -Sor -Gcan be used for git log. The difference between the two is that it -Stakes a fixed line (representing the line of code you want to match), while it -Gdoes the same thing, but takes a regular expression:

git log --oneline -S 'fixed string'
git log --oneline -G '^foobar$'

-S -G , , / . --patch -p, , .

Linux Kernel git log:

-S <string>

, <string>. , , diff; . gitdiffcore (7).

-G <regex>

, <regex>.

+3

git-blameall. , - , , . .

+2

Source: https://habr.com/ru/post/1544392/


All Articles