Git blame 有助于调查为什么文件中的代码是某种方式。 git gui更好的是,它允许您在添加代码时及时后退以查看文件的上下文。
然而,git blame <file>
和 git gui blame <file>
删除文件后不起作用。错误将显示为:
fatal: cannot stat path 'file': No such file or directory
如何责怪删除的文件?
最佳答案
git blame
git blame
在提供包含文件的提交引用时起作用。找到最近的有日志的:
$ git log -2 --oneline -- example/path/file.txt
fffffff deleting file.txt
eeeeeee Last change to file.txt before deleting.
然后责怪父提交:
$ git blame eeeeeee -- example/path/file.txt
git gui blame
然而,git gui blame
不会以这种方式工作。解决方法是在包含该文件的最后一次提交时浏览存储库,然后从 GUI 选择文件并启动 blame 查看器:
$ git gui blame eeeeeee example/path/file.txt
(注意:使用log -2
和eeeeeee
代替fffffff^
因为git gui blame
不能处理 fffffff^:example/path/file.txt
)
关于git - 我怎么能责怪 Git 中删除的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37084243/