Skip to content

One Move, a Dimensional Strike: Say Goodbye to Handwritten Commit Messages with Git + AI ​

Still worrying about writing Commit Message? Still git log Seeing a bunch of “update”, “fix”, “aaa” in there and wanting to bang your head against the wall? Today I’ll teach you a combo move: combine Git and AI, and from then on you’ll write commit messages more standard than anyone else’s.

Pain point: the pitfalls you fall into every day ​

Have you ever experienced a scenario like this:

  • Developing a new feature, I toiled away and changed a bunch of files.

  • To be safe, every time you change a little, ...git commit -m "wip" or git commit -m "fix"

  • Finally, the feature is working. Looking back:A dozen or so small commits, all with garbage messages.

  • I want to squash it into one big commit and write a good summary, but I forgot what I changed.

So you begin:

  • Go through the files one by one and compare them visually.

  • facing git diff Spacing out

  • Finally, squeezed out a sentence.feat: 优化功能 Get it over with.

Are you tired?

TIP

According to the JetBrains 2024 Developer Report, more than 60% of developers consider “writing Commit Messages” one of their least favorite Git operations.

Solution: a two-step approach, with AI helping you wrap up ​

Step 1: Merge multiple commits back into the working directory ​

Suppose you recently have 3 small commits and want to handle them together:

Method 1 (one-step, recommended):

bash
# Undo the last 3 commits and return the changes directly to the working directory.
git reset HEAD~3

Method 2 (step-by-step understanding):

bash
# First return to the staging area.
git reset --soft HEAD~3

# Then return it from the staging area to the working tree (required! otherwise git diff won't show the changes)
git restore --staged .

After execution:

  • ✅ All commits have been reverted

  • ✅ All changes are sitting intact in the workspace

  • ✅ Can be used git diff See the complete change

Note

git reset --soft and git reset --mixed The difference between:

  • --soft: changes return to the staging area (at this point git diff is empty)

  • --mixed(default, i.e.git reset): Changes go directly back to the workspace (git diff See full changes)

Step 2: Feed the Diff to the AI ​

bash
git diff > changes.txt

Open changes.txt, Select all and copy, toss it to AI, and add this sentence:

Please generate a standardized Git branch name and commit message based on the following Git diff content, using the Conventional Commits format (feat/fix/docs/style/refactor, etc.), with a Chinese description, and include the main changes and impact scope.

AI will output something like the following to you, which contains two parts.Can be copied and executed directly Information:

Git Branch

bash
git checkout -b feat/order-wechat-alipay-integration

Git Commit Message

bash
git commit -m "feat(order module): integrate WeChat Pay and Alipay

- Added PaymentService interface and WeChat/Alipay implementation classes
- Add payment callback handling logic
- Order state machine extension: Pending payment → Payment in progress → Paid
- Added payment timeout cancellation mechanism
- Add relevant unit tests

Perfect! Ten times more detailed than your handwritten version, and it conforms to the specification, with consistent semantics for branch and commit.

Complete command flow (one-click copy) ​

bash
# 1. Undo the most recent N commits, moving the changes back to the working directory (replace N with your number)
git reset HEAD~3

# 2. Generate diff file
git diff > changes.txt

# 3. Give the contents of changes.txt + prompt to the AI
#    → Get the branch creation command + commit command

# 4. One-click execution of the two commands returned by AI
git checkout -b <AI-generated branch name>
git add .
git commit -m "<AI-generated commit message>"

Advanced trick: make it a Git alias ​

Turn the undo operation into a single command:

bash
git config --global alias.uncommit '!git reset --soft HEAD~1 && git restore --staged .'

From now on, you only need to:

bash
git uncommit
git diff > changes.txt
# Copy to AI → get branch + commit → execute

Why is this a dimensionality reduction attack? ​

Comparison itemDo it with the naked eyeAI does
When modifying multiple filesDazzled by the sightAutomatic summary
Summarization abilityEasy to miss details.List item by item
Format specificationToo lazy to write type and scopeAuto-add feat:,fix:
Branch namingName it casually, whatever.Semanticization and standardization
branch and commit consistencyIt might not match.Complete unification
moodIrritableRelaxed

Commit Message is no longer a blemish on your Git history, but the best changelog for your project.

Further thinking: How else can we play? ​

The core idea of this workflow can be applied to more scenarios:

1. Code Review assistance ​

bash
git diff main...feature > review.txt
# Throw it to AI to generate CR key points.

2. Automatically generate Changelog ​

bash
git log --oneline --pretty=format:"%s" v1.0.0..HEAD > commits.txt
# Give it to AI to group by type and output a Changelog in Markdown format.

3. Multilingual commit messages ​

bash
git diff > changes.txt
# Have the AI generate both English and Chinese commit messages at the same time.

Final Thoughts ​

The core of this workflow is not about being lazy, but rather Save your energy for writing code, and leave the summarizing to the machine..

Git provides fine-grained operational tools (reset,restore,diff), AI provides powerful text understanding capabilities. Put them together, and you get a An automated, standardized, zero-brainpower Commit generator.

Give it a try—once you use it, you won’t be able to go back.

INFO

If you find it useful, feel free to share it with friends around you who are still handwriting “update”.

Reference materials ​

Last updated on11/07/2026, 02:16 PM
@fishfinal | @fishfinals | [email protected]