How can I find which commit entered a specific line in git? Or is there a better alternative?

Imagine a class in a git project that has undergone 1000 commits that are revisited again and again. Do I have the opportunity to check exactly when (at which to commit) a certain line of code was introduced into the class?

If not, is there an alternative to moving to each commit to find a set of rows that I have a particular interest in?

Ty.

+5
source share
2 answers

git bisect , - (. http://git-scm.com/book/en/Git-Tools-Debugging-with-Git) , , , . O (log n) O (n), ...

, , git blame.

+3

? , ? , . . git log:

-S<string>
    Look for differences that introduce or remove an instance of <string>. Note that this is different than the string simply appearing in diff output;
    see the pickaxe entry in gitdiffcore(7) for more details.

, public class Foo {, , :

git log -S"public class Foo"

, --:

git log -S"public class Foo" -- Foo.java

, :

git log -S<string> [-- <file>]
+10

All Articles