Git将责任归咎于尚未提交的重命名文件



我有一个使用git mv oldfilename newfilename 重命名的文件

在我提交此更改之前,如何对此文件进行git指责?由于尚未提交重命名,因此未提取该重命名。

> git blame newfilename
> fatal: no such path 'newfilename' in HEAD

并且旧文件名已不存在。

> git blame oldfilename
> fatal: cannot stat path 'oldfilename': No such file or directory

如果你告诉git关于文件移动的事情,你会认为它会解决的。但事实并非如此。

--contents开关将实现您想要的功能。从git-blame手册页。。。

--contents <file>
   When <rev> is not specified, the command annotates the changes starting
   backwards from the working tree copy. This flag makes the command pretend as if
   the working tree copy has the contents of the named file (specify - to make the
   command read from the standard input).

git blame --contents newfilename -- oldfilename将对HEAD中出现的旧文件名进行指责日志,但使用新文件名的内容作为最新修订。

对于对因任何原因而不再存在的文件进行指责的一般问题,请传入git blame的特定修订版。git blame <rev> -- <file>。因此,git blame HEAD -- oldfilename将给出最后一次提交时旧文件名的指责日志。

--通常用于告诉命令停止处理选项,并将下面的内容视为正常参数。然而,git blame似乎重载了正常意义上的"不查找文件"。。。我想。从文件中还不完全清楚。

有关详细信息,请参阅"git指责"手册页中的"指定范围"。

最新更新