为什么Git在没有--find-renames的情况下检测到重命名? [英] Why does Git detect rename without --find-renames?
问题描述
我运行git log --name-status -1
,Git检测到重命名.根据我在 https://git-scm.com/docs/git-log,仅在指定--find-renames时才启用重命名检测.为什么Git在没有--find-renames
的情况下检测到重命名?
I run git log --name-status -1
and Git detects a renaming. From what I read on https://git-scm.com/docs/git-log, renaming detection is only enabled when --find-renames is specified. Why does Git detect rename without --find-renames
?
如果开箱即用地启用了重命名检测,那就太好了.我相信Tests/ProgramTest.cs => Tests/StringExtensionsTest.cs也是一个重命名.如何要求Git计算相似性指数并将其显示为重命名?
If renaming detection is enabled out of box, it's great. I believe Tests/ProgramTest.cs => Tests/StringExtensionsTest.cs is also a rename. How do I ask Git to calculate similarity index and show it as rename?
推荐答案
如果有指导,Git将检测到重命名.该方向在各种控制旋钮下;其中之一是diff.renames
设置. diff.renames
的默认值在Git 2.9之前的Git版本中为false
,并且 true
.
Git will detect renames if directed. This direction is under various control knobs; one of these is the diff.renames
setting. The default value for diff.renames
is false
in Git versions predating Git 2.9, and true
in Git versions from 2.9 onward.
(请注意,命令行标志会覆盖diff.renames
,因此您可以根据需要显式关闭重命名检测 .还请注意,像git diff-tree
这样的管道"命令通常不会读取用户配置设置,例如diff.renames
和diff.renameLimit
,以便脚本行为是可预测的,而不是取决于用户的配置设置.)
(Note that command line flags override diff.renames
, so you can explicitly turn rename detection off if you want. Note also that "plumbing" commands like git diff-tree
generally do not read user configuration settings such as diff.renames
and diff.renameLimit
so that script behavior will be predictable, rather than depending on the user's configuration settings.)
这篇关于为什么Git在没有--find-renames的情况下检测到重命名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!