DEV Community

Cover image for Automate Your Git Commits with AI - Introducing `git-ai-commit
syedharis14
syedharis14

Posted on

1

Automate Your Git Commits with AI - Introducing `git-ai-commit

Writing commit messages can be tedious, and maintaining consistency in commit logs is often overlooked. That’s why I built git-ai-commit – an AI-powered CLI tool that generates meaningful, structured commit messages based on staged changes. πŸ“βœ¨

🎯 Why git-ai-commit?

  • Saves Time – No need to think about commit messages manually!
  • Consistent Messages – Follows Conventional Commits format.
  • Multi-Language Support – Generate commit messages in English, French, Spanish, Urdu, Arabic, and more!
  • Auto-Commit – Directly commit without manual approval.
  • Usage Tracking – View CLI usage statistics.
  • Smart AI Processing – Analyzes git diff and suggests precise messages.

πŸ› οΈ Installation

Install git-ai-commit globally using NPM:

npm install -g @syedharis14/git-ai-commit
Enter fullscreen mode Exit fullscreen mode

πŸš€ How to Use It

1️⃣ Generate an AI-powered commit message

git-ai-commit generate
Enter fullscreen mode Exit fullscreen mode

2️⃣ Auto-commit using AI-generated message

git-ai-commit generate --auto-commit
Enter fullscreen mode Exit fullscreen mode

3️⃣ Copy commit message to clipboard

git-ai-commit generate --copy
Enter fullscreen mode Exit fullscreen mode

4️⃣ Generate message in a specific language

git-ai-commit generate --lang fr
Enter fullscreen mode Exit fullscreen mode

5️⃣ View usage statistics

git-ai-commit stats
Enter fullscreen mode Exit fullscreen mode

πŸ” How It Works

  1. git-ai-commit fetches the staged git diff.
  2. It sends the diff to OpenAI’s API for analysis.
  3. AI generates a Conventional Commit-style message.
  4. The message is displayed, copied, or committed automatically.

πŸ“¦ Example Commit Message

Before:

git add .
git-ai-commit generate
Enter fullscreen mode Exit fullscreen mode

AI Response:

feat(auth): add OAuth2 login endpoint
Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Configuration

Create a .git-ai-commitrc in your project to customize behavior:

{
  "model": "gpt-4o",
  "maxLines": 100,
  "autoCommit": false,
  "copy": false,
  "lang": "en",
  "analytics": true
}
Enter fullscreen mode Exit fullscreen mode

πŸš€ Open Source & Contribution

This project is open-source and I’d love your contributions! Feel free to star ⭐ the repo, open issues, or contribute!

πŸ”— GitHub Repository

πŸ”— NPM Package


What do you think about git-ai-commit? Would this help improve your workflow? Let me know in the comments! πŸš€

Image of Timescale

πŸ“Š Benchmarking Databases for Real-Time Analytics Applications

Benchmarking Timescale, Clickhouse, Postgres, MySQL, MongoDB, and DuckDB for real-time analytics. Introducing RTABench πŸš€

Read full post β†’

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay