claude-code - 💡(How to fix) Fix [BUG] /commit-commands:commit doesn't work when there are no commits yet [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49688Fetched 2026-04-17 08:34:12
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

Error Message

⎿ Error: Shell command failed for pattern "!git log --oneline -10": [stderr]

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Reopening the same issue as before. It is still occurring with the latest version. https://github.com/anthropics/claude-code/issues/24881

The commit command doesn't work when there are no commits yet. Here's what happens:

/commit-commands:commit
⎿ Error: Shell command failed for pattern "!git log --oneline -10": [stderr] fatal: your current branch 'main' does not have any commits yet

What Should Happen?

It should help the user create an initial commit.

Error Messages/Logs

Steps to Reproduce

Create a new repo with git init Run Claude Code Make sure commit-commands plugin is installed Run /commit-commands:commit

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.112

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by modifying the commit command to handle the case where there are no commits yet, potentially by adding a check for an empty commit history before running the git log command.

Guidance

  • The error occurs because the git log command fails when there are no commits in the repository, so a check for this condition should be added to the commit command.
  • To verify the issue, create a new repository with git init, install the commit-commands plugin, and run /commit-commands:commit to see if the error occurs.
  • The commit command should be modified to handle the case where there are no commits yet, possibly by creating an initial commit if none exist.
  • The git log command can be replaced with a command that checks if the repository has any commits, such as git rev-parse --is-inside-work-tree or git rev-list --count HEAD.

Example

No code example is provided as the issue does not specify the exact code that needs to be modified.

Notes

The issue may not be a regression, but rather a missing feature in the commit-commands plugin. The fix may require modifying the plugin to handle the case where there are no commits yet.

Recommendation

Apply workaround: The recommended solution is to modify the commit command to handle the case where there are no commits yet, as this is a specific and targeted fix for the issue at hand.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] /commit-commands:commit doesn't work when there are no commits yet [1 comments, 2 participants]