git - 我怎么能责怪 Git 中删除的文件?

标签 git

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 -2eeeeeee代替fffffff^因为git gui blame不能处理 fffffff^:example/path/file.txt)

关于git - 我怎么能责怪 Git 中删除的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37084243/

相关文章:

git - 如何恢复 `git rm abc.c`之后的文件?

macos - .bash_profile 中 `$PATH` 导出的末尾或开头的 `PATH`(对于 Mac 上的 Git)

git - 是否可以从 .git 文件夹中获取文件

带标签的 Git 子目录过滤器

git - 让 Git 覆盖本地更改但保留未跟踪的文件

git - 请求的URL返回错误: 403 in git repository如何解决

git - 在 git subtree pull 之前是否需要 git fetch?

GitFlow : what is difference between release and master branches?

git - 如何压缩一个分支中的提交?

git - 为什么 Git 忽略 .vs 目录?