0

this happened today last few hours, have not updated git, but all of my git commits have no message I do a commit

git commit -m "fixed the headline level"

and when I do git log I see

   feat(custom):

very irritating, how do I get my git commit messages back?

I am on Mac, Sonoma 14.4.1 using terminal updated with latest ZSH, however none of that stuff has changed today either.

4
  • if its only been happening for a few hours, have you tried rebooting and whatnot? Commented May 14 at 16:19
  • Does git show show a commit message?
    – 8bittree
    Commented May 14 at 18:29
  • no git show shows feat(custom): followed by empty lines after which a git diff of the last changes.
    – user254694
    Commented May 14 at 20:34
  • You appear to have some Git hook that adds the conventional commits stuff. It must be malfunctioning. I suggest you check that. The problem is not with git log.
    – Daniel B
    Commented May 16 at 8:17

1 Answer 1

1

In git, the commit messages themselves also take part in the computation of the commit ID. That is, one cannot retroactively forge one of the commit messages and stay at the same commit ID.

Now, of course it's possible that somehow an attacker modified your git repository, replaced all your commit messages with the string you're seeing, but it's extremely unlikely; also it would result in all your commit IDs having changed from their previous values.

I find it way more likely that your repository is absolutely fine, it's just that the way you display these commit messages is configured to display this fixed string.

I can reproduce your behavior with commands like

git log --format=format:'feat(custom):%n%n'
git show --format=format:'feat(custom):%n%n'

where I explicitly tell git to use a format string whose value is a fixed string (including a couple of trailing newlines), and no placeholder for the actual commit message.

I suspect that somehow you have configured your git to use such a format by default. I'd look at the git configuration files (system-wide, user-wide, repo-specific) and do a recursive grep for the words "feat" or "custom", this might point to the location where the default commit log format is overridden to this fixed string.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .