Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this git commit exist in the log but not in the log of the file?

Tags:

git

How can I investigate how this commit got dropped?

The following commands show no history of the commit in the log:

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

But the following all show the commit in the log:

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

UPDATE: No files were renamed in the commit. Here's the output of 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(-)
like image 322
Steve McKinney Avatar asked Feb 14 '12 22:02

Steve McKinney


2 Answers

Usually happens with a bad merge (i.e merge conflict)

in order to locate it

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

You will see the missing code as well as the commit ids

like image 79
hbt Avatar answered Nov 15 '22 20:11

hbt


It turns out that someone's merge commit was the culprit. Any information that wasn't included was lost in that merge. And since the merge commit didn't add or delete anything it didn't show up in the log run on the file.

The give away was git show 5eaa666 only had a subset of my changes.

I added the commit back in by cherry picking: git cherry-pick 5034d44

like image 25
Steve McKinney Avatar answered Nov 15 '22 20:11

Steve McKinney