G
G
Gruberhoff2016-01-15 20:25:47
git
Gruberhoff, 2016-01-15 20:25:47

How to find out by whom and in which commit a line was deleted?

Such a question: I need to find out who deleted one line from a file.
That is, someone removed one line from the code, I use phpStrom and you can’t see in the annotations in which commit they did it. Are there any ways to find out?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2016-01-15
@Gruberhoff

if you know what was in this line, then
git log -S <string> path/to/file

C
Cobalt the Terrible, 2016-01-15
@CobaltTheTerrible

git blame --reverse start_rev..end_rev /path/to/file

--reverse
Walk history forward instead of backward. Instead of showing the revision in which a line appeared, this shows the last revision in which a line has existed. This requires a range of revision like START..END where the path to blame exists in START.

A
abcd0x00, 2016-01-16
@abcd0x00

There is also git bisect .
The meaning is this: you make a shell script with grep'om on the desired line, which returns 0 or 1, depending on the result of this grep'a. And then you run git bisect with this script (how - you will find in git bisect --help).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question