为什么这个git提交存在于日志中但不存在于文件的日志中?

Ste*_*ney 9 git

我该如何调查这个提交是如何被删除的?

以下命令不显示日志中的提交历史记录:

  • git log -p apps/grants/views.py
  • gitk apps/grants/views.py

但以下都显示了日志中的提交:

  • git log
  • git log --follow -p apps/grants/views.py
  • git show 5034d44861fcc39fc28b069501577c8d15321b4f

更新:在提交中没有重命名文件.这是输出git log --stat:

 apps/articles/views.py                    |    4 +-
 apps/grants/tests.py                      |   16 +++++++-----
 apps/grants/views.py                      |   20 +++++++++------
 static/css/modules.css                    |   36 ++++++++++++++--------------
 templates/articles/learning_landing.html  |    2 +-
 templates/grants/fellow_detail.html       |   10 ++++++++
 templates/modules/fellow_search_form.html |    2 +-
 7 files changed, 53 insertions(+), 37 deletions(-)

hbt*_*hbt 10

通常发生错误的合并(即合并冲突)

为了找到它

git log -U -m --simplify-merges --merges -- filename

您将看到丢失的代码以及提交ID


Ste*_*ney 5

事实证明,某人的合并提交是罪魁祸首。合并中所有未包含的信息都会丢失。而且由于合并提交没有添加或删除任何内容,因此它没有显示在文件运行日志中。

赠送的git show 5eaa666只是我的一部分更改。

我通过挑选樱桃重新添加了提交: git cherry-pick 5034d44