9

I use git blame command to see in which commit have been added some particular code line, but sometimes I bump into the same problem: someone has made some kind of code formatting, or has changed function interface and refreshed all client code.

Eventually git blame show me only this last commit on particular code line. How ignore this commit and see what happened before it?

Of course I can checkout on commit before format-edited commit and see blame again, but it may take a lot of time on huge project and doesn't appropriate.

Malov Vladimir
  • 490
  • 4
  • 11

1 Answers1

5

I think you are looking for the -w option that excludes white space. According to the man page.

Ignore whitespace when comparing the parent’s version and the child’s to find where the lines came from.

Moved code can also be excluded. See the -M and -C options. See https://git-scm.com/docs/git-blame

Michiel Leegwater
  • 1,172
  • 4
  • 11
  • 27
  • Michiel Leegwater, thanks! I have tried command with additional options -M and -w and it partially helps me. I run git blame -wM -L 8810,+5 fileName.cpp and just git blame -L 8810,+5 fileName.cpp and see diference. It works – Malov Vladimir Aug 02 '19 at 13:53
  • But I still have got linked problem. For example someone has replaced all Log::Info function calls on LOG_INFO. After it I see this commit in every line with LOG_INFO and can't ignore this commit to see who add original log call – Malov Vladimir Aug 02 '19 at 14:00
  • 1
    It seems that git hyper blame solves that for you. https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html The —incremental option might provide the result as well but may be harder to read. – Michiel Leegwater Aug 02 '19 at 14:08
  • 3
    If you like git hyper blame then you'll be pleased to know that Git 2.23 introduced git blame --ignore-rev which is similar but arguably more powerful. – Michael Platings Sep 07 '19 at 14:01