iTranslated by AI
Generating Commit Messages in the Terminal using GitHub Copilot
In VS Code's Source Control, you can have GitHub Copilot write commit messages for you. Since I usually perform git operations in the terminal, I looked into whether there's a way to generate commit messages on the terminal as well.
In the case of VS Code's Integrated Terminal
In VS Code's terminal, after executing the git add command, clicking the icon on the far left of the terminal will display a menu called "Generate Commit Message." Clicking here allows GitHub Copilot to generate a commit message for you.

In cases where processes are run at commit time via pre-commit or similar tools, executing from the terminal might be more convenient than using Source Control.
In the case of Terminals other than VS Code
For environments other than VS Code, I looked into whether the GitHub Copilot CLI could be used. There is a command called gh copilot suggest, but it is strictly for suggesting commands and was not intended for generating text like commit messages.
However, since natural language can be used as input for the suggest command, I wondered if I could pass the git diff and have it suggest a git commit command along with a commit message.
After trying out several prompts, I set up a git alias like the one below, enabling commit message generation with a command like git cs.
cs = "!f() { diff=$(git diff --staged); gh copilot suggest -t shell \"Based on the following diff, generate a concise commit message and suggest a shell command that pipes this message into 'git commit -e -F -'. The message should follow the conventional commit format.\\n\\n${diff}\"; }; f"
After setting this alias, running git add and then git cs will prompt GitHub Copilot to suggest a command that includes a commit message.
% git cs
Welcome to GitHub Copilot in the CLI!
version 1.1.1 (2025-06-17)
I'm powered by AI, so surprises and mistakes are possible. Make sure to verify any generated code or suggestions, and share feedback so that we can learn and improve. For more information, see https://gh.io/gh-copilot-transparency
Suggestion:
echo "docs: remove sample file section from README" | git commit -e -F -
? Select an option [Use arrows to move, type to filter]
> Copy command to clipboard
Explain command
Execute command
Revise command
Rate response
Exit
Running the suggested command opens your editor with the commit message generated by Copilot already filled in. From there, you can review and revise the message to finalize the commit.
I haven't tested whether it can generate Japanese or how it handles large diffs, but it seems usable for simple changes.
Discussion