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
This functionality is provided through git blame -C
.
The -C
option drives git into trying to find matches between addition or deletion of chunks of text in the file being reviewed and the files modified in the same changesets. Additional -C -C
, or -C -C -C
extend the search.
Try for yourself in a test repo with git blame -C
and you'll see that the block of code that you just moved is originated in the original file where it belonged to.
From the git help blame manual page:
The origin of lines is automatically followed across whole-file renames (currently there is no option to turn the rename-following off). To follow lines moved from one file to another, or to follow lines that were copied and pasted from another file, etc., see the
-C
and-M
options.