git blame -C -C <filepath>
This command helps you track who last modified each line of a file and also detects code copied from other files in the project.
It runs git blame on the target file path, applying the first -C flag to detect lines copied from other files and the second -C flag to trace those copies back through their original commits; the -C flag finds code copied from elsewhere, and using it twice (-C -C) extends that detection through multiple generations of copies, while the <filepath> specifies which file to analyze.
You can vary this by using a single -C to detect copies without full history, adding -M to track lines moved within the same file, -w to ignore whitespace-only changes, -L <start>,<end> to limit annotation to a specific line range, -e to show author emails, or -p for a porcelain (scripting-friendly) format. Related commands include git log -L to follow a line range in history and git annotate as an alias for git blame.
Examples:
git blame -C -C src/app.jsgit blame -C -C README.md