1

Preface: I know there are a lot of questions about how to change the git commit message without changing the hash (such as this one). But I am not asking how to do that, because like many of you, I don't believe it to be possible. I have some evidence here that could imply a commit message was changed even though the hash was not, and I am asking for help finding the explanation of what has happened here.

Here is a screenshot of a simple git log command from earlier today: git log output 1

And here is a screenshot of the same git log command a few hours later. enter image description here

Note that the hash is the same as before, but the log message is different. What could cause this?

Additional info:

  • In both cases, the output is from this exact command: git log
  • I probably did call git pull or similar commands in between these two events
  • This commit is the result of a squash/merge on a GitHub pull request via UI. The first commit message appears to be the auto-suggest description that git generates. The second message is the one the author remembers writing to replace the auto-suggest while doing the squash/merge.
  • I don't suspect any deliberate use of git notes here (I just learned about those today)
  • There are no custom scripts that would be modifying this output.
JakeStrang
  • 167
  • 7
  • Could be an error. Or if the repo is under multiple collaborators, it could have been changed on the server. – Peter Nielsen Jun 01 '21 at 18:11
  • @PeterNielsen thanks, there are multiple collaborators, but are you saying that a server (in this case GitHub) could rewrite a commit message without changing the commit hash? – JakeStrang Jun 01 '21 at 18:21
  • 6
    It doesn't look like the message has changed, just the presentation. Perhaps there is an alias for `git log` somewhere (eg in your git config) that changed the format of the output between the invocations. – William Pursell Jun 01 '21 at 18:23
  • @WilliamPursell that would make sense, but in this case the output from the second image is the literal commit message (not truncated except that the line runs off the image), have had multiple collaborators on different devices confirm that. The similarities between the messages are because the author deleted the additional lines from the auto-suggest when doing the squash/merge. – JakeStrang Jun 01 '21 at 18:27
  • You're suggesting the commits are different (due to squash/merge) which is hard to believe. Do you still have access to both? If yes (consider keeping it that way until this is explained), are the commit datetimes different? You can see it with: `git log --pretty=fuller` – TTT Jun 01 '21 at 18:38
  • 1
    @TTT Actually no, I believe both commits to have exactly the same contents. I mention the squash/merge to explain how the commit was produced (as in, _both_ screenshots happened _after_ this squash/merge). There were no squashes or merges between the screenshots. Unfortunately I can't reproduce the first screenshot anymore. – JakeStrang Jun 01 '21 at 18:46
  • 1
    @JakeStrang got it; makes sense. So the "* fixed typo" line is still there, just off the screen, presumably with newlines still in the commit message but not being displayed in `git log` anymore? (And is it only in your window?) Is it only that message or are other commit messages not showing the newlines anymore in your window? – TTT Jun 01 '21 at 18:57
  • @TTT apologies I think I said something confusing in a previous comment: `the second image is the literal commit message (not truncated except that the line runs off the image)`. By "not truncated", I meant that what you see in the second image is the full commit message. The line that runs off the image is identical to the line that runs off the side in the first image. So the "* fixed typo" appears nowhere in the commit message from this point on. – JakeStrang Jun 01 '21 at 19:02
  • 3
    OK. I think the confusion arose from "exactly the same contents" which would include the commit message. I feel like the extra lines must still be there, but for some reason you can no longer see them. Can anyone else see them? (I think you said no in a previous comment) Can you see them in another tool, or from another copy of the repo? – TTT Jun 01 '21 at 19:16
  • 5
    Given that `git log` runs commit messages through your pager, perhaps something happened to change the pager / how-the-pager-operates, changing the appearance of the commit message from the before to the after. That's about the only thing I can guess here. – torek Jun 01 '21 at 21:20
  • 3
    I agree with the above comments; I think the consensus is that the commit is completely unchanged and you are just being _shown_ fewer lines of the message, for some external reason. – matt Jun 01 '21 at 21:29
  • 3
    `git --no-pager show e0cec7455` – phd Jun 01 '21 at 22:37
  • @JakeStrang No, it could be that a collaborator did it. – Peter Nielsen Jun 02 '21 at 22:49

0 Answers0