Several times, I have come across the statement that, if you move a single function from one file to another file, Git can track it. For example, this entry says, \"Linus sa
As of Git 2.15, git diff now supports detection of moved lines with the --color-moved option. It works for moves across files.
It works, obviously, for colorized terminal output. As far as I can tell, there is no option to indicate moves in plain text patch format, but that makes sense.
For default behavior, try
git diff --color-moved
The command also takes options, which currently are no, default, plain, zebra and dimmed_zebra (Use git help diff to get the latest options and their descriptions). For example:
git diff --color-moved=zebra
As to how it is done, you can glean some understanding from this email exchange by the author of the functionality.