Find out all GIT changes in a specific line of the file

I have a line of code that has recently been changed to an idle state.

How to find out who and in what commit changed this particular line?

I tried

git log -Sone_distinct_string_from_that_line --pretty=format:'%h %an -- %s -- %ad'

Which shows all commits with comments and authors that haven't changed anything, where the line contained "one_distinct_string_from_that_line", but how can I see the actual changes they made?

EDIT:
I also installed git-guiand looked at the line with git gui blame filename, but for this line there is only one commit change, although there were definitely more changes.

I checked with the graphical gui smartgit to see all the changes made to this file manually and found 3 commits where this line was explicitly edited (was deleted first #and then added again in another commit)

Is there any other way that does not relay the git guilt functions and does not resolve under the assumption that the string is in commit-diff?

+1
source share
3 answers

git blame. The -L option takes a series of lines, and you can select a file as for git log. So, it git blame -L 10,20 -- my/file.txtwill show the latest git commit that touched each of the lines in this file. git gui blame my/file.txtdoes the same job, but with a user interface so you can go back.

+5
source

.git/config [alias]:

findchange = !sh -c \"git log --pretty=format:'COMMIT %C(yellow)%h %an -- %s -- %ad%C(reset)' -G'$1' -p --word-diff-regex='[A-Za-z0-9]+|[^A-Za-z0-9]|$1' --color=always ${@:2} | egrep '$1|^COMMIT|-{3} a\\/|\\+{3} b\\/' \"

:

git findchange 'yourText'

:

  • , .
  • -p , , , p .
  • --word-diff-regex . , , .
    • ; ,
  • --color=always egrep.
  • egrep , :
    • , ( , )
+4

gitk, - :

gitk -Sone_distinct_string_from_that_line -- /some_sub_dir/containing/the/file

, , one_distinct_string_from_that_line diff. , , , .

-- , .

0

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


All Articles