Everyone has been there, that piece of code of which you think:
“Wow, what a piece of crazy code, the person who wrote that should be ashamed of themselves.”
(Of course it wasn’t you! It’s never you!) or maybe you’re more positive minded, and you think:
“That's a nice piece of code, who made this?”
The tool you are most likely to use is
git blame (if it's not the tool of choice, please consider it!).
git blame comes one little issue, it gives a lot of false positives, for example, someone moved the piece of code around, or removed a trailing whitespace. All those actions will cause the
git blame to point to them.
To make sure you only get the person who changed the code itself (Ignoring white spaces and other trivial changes), you can use the following flags
$ git blame -w # Ignore white spaces $ git blame -M # Ignore moving text $ git blame -C # Ignore text that has moved from another file