Git does not do rename tracking nor copy tracking, which means it doesn't record renames or copies. What it does instead is rename and copy detection. You can request rename detection in git diff
(and git show
) by using the -M
option, you can request additional copy detection in changed files by using the -C
option instead, and you can request more expensive copy detection among all files with -C -C
. See the git-diff manpage.
-C -C
implies -C
, and -C
implies -M
.
-M
is a shortcut for --find-renames
, -C
means --find-copies
and -C -C
can also be spelled out as --find-copies-harder
.
You can also configure git to always do rename detection by setting diff.renames
to a boolean true value (e.g. true
or 1
), and you can request git to do copy detection too by setting it to copy
or copies
. See the git-config manpage.
Check also the -l
option to git diff
and the related config variable diff.renameLimit
.
Note that git log <pathspec>
works differently in Git: here <pathspec>
is set of path delimiters, where path can be a (sub)directory name. It filters and simplifies history before rename and copy detection comes into play. If you want to follow renames and copies, use git log --follow <filename>
(which currently is a bit limited, and works only for a single file).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…