git move将文件视为新文件

rau*_*mis 2 git github bitbucket intellij-idea

尝试使用带有intellij-idea的git在项目中移动文件,重构由IDE修改导入和包完成,项目的一些文件被删除并再次添加,因为在GIT中有一定比例的修改,在它上面,文件被检测为新的.

我想修改此百分比否以将文件检测为新的.可能吗?

mar*_*t1n 5

实际上,Git移动操作与删除和添加步骤相同(此处有更多信息).

但是,您可以使用移动操作检测一定量的更改git log.请查看git-log(1)手册页中的以下选项:

-M[<n>], --find-renames[=<n>]
   If generating diffs, detect and report renames for each commit. For
   following files across renames while traversing history, see
   --follow. If n is specified, it is a threshold on the similarity
   index (i.e. amount of addition/deletions compared to the file’s
   size). For example, -M90% means Git should consider a delete/add
   pair to be a rename if more than 90% of the file hasn’t
   changed. Without a % sign, the number is to be read as a fraction,
   with a decimal point before it. I.e., -M5 becomes 0.5, and is thus
   the same as -M50%. Similarly, -M05 is the same as -M5%. To limit
   detection to exact renames, use -M100%
Run Code Online (Sandbox Code Playgroud)

  • @raulgomis:历史记录没有"删除",部分原因是因为任何*文件*实际上都没有"历史记录".而是使用提交计算"文件历史".例如,如果提交A有一组包含blob ID = <hash>的文件,并且提交B有一组包含blob ID = <samehash>的文件,那么该文件的内容(无论其名称是什么)都是*在A和B中相同*但是,`git log --follow`和`git log --diff`使用相似性检测器,因为更改任何文件中的单个位会更改其哈希值.如果没有图表和一些理论,这很难解释. (2认同)