Current location: Home> Cursor ai Tutorial> Use Cursor ai to generate professional Git Commit Message in one click

Use Cursor ai to generate professional Git Commit Message in one click

Author: LoRA Time: 21 Mar 2025

Filling in Git Commit Message is often a tedious task during daily development, especially when dealing with multiple modifications and complex changes. If you have a headache about this, today we will take a look at how to generate professional Git Commit Message with Cursor ai in one click to make your development work easier and more efficient.

4a00632md5.jpg

How to generate Git Commit Message in Cursor ai ?

View code changes: Before submitting a Git Commit Message, we need to understand what changes have been made since the last commit. Cursor ai provides a command: @Commit (Diff Of Working State), through which you can quickly obtain all the modifications of the current workspace. This step ensures that you have a clear idea of what updates are included with each commit.

Generate submission information with prompt words: Cursor ai provides a custom Git submission information template, and combines enumeration types and submission details to help us quickly generate submission information that meets the specification based on the modified content. The following is a template and type reference for submitting information:

Git Submit Information Template:

 <type>(<scope>): <subject>

// blank line

<body>

// blank line

<footer>

Among them, the header is the part that must be filled in, and the Body and Footer are optional. Pay attention to the content of each part of the content should not exceed 72 characters (or 100 characters) to avoid automatic line wrapping affecting the aesthetics of the information.

Submit Type (Type) Enumeration:

  • feat: New features

  • fix: Bug fix

  • docs: Document update

  • style: Format (no changes that affect code execution)

  • Refactor: Refactor (no new features and no bug changes are fixed)

  • test: Add test

  • chore: Changes to the build process or auxiliary tool

Example: Generated Git Commit Message

Suppose you modified a script called debug.sh and added some comments to improve readability, you can generate Git commit information using the following command:

 docs(debug): Add comments to debug.sh scripts Added Chinese comments to debug.sh scripts to improve the readability and maintainability of the scripts.

- Added comments for commands to install dlv - Added comments for commands to start debugging