Save time generating your git commit message

No more time wasted crafting the perfect commit message.

Natt Nguyen·February 13, 2023 (2 years ago)·3 min read

#git
#open-ai
#developer-experience
Save time generating your git commit message

There are only two hard things in Computer Science: cache invalidation and naming things. — Phil Karlton

Developers should have good git commit messages for several reasons:

  • Clarity: Good commit messages provide clear and concise information about the changes made in the commit. This makes it easier for other developers to understand what changes were made and why.
  • Documentation: Commit messages serve as documentation for the project, allowing developers to understand the history and evolution of the codebase.
  • Collaboration: Good commit messages facilitate collaboration between developers by making it easier to track changes and resolve conflicts.
  • Debugging: Clear commit messages can help with debugging, as they provide context and information about changes made to the code.
  • Code maintenance: Well-written commit messages make it easier to maintain the codebase over time, as they provide a clear record of changes and the rationale behind them.

Developers can now save time by generating your commit message using AI Commits by Hassan El Mghari.

We need a package manager and an Open AI API key. You can find the offical way to install aicommits here. In this order, we first need to globally install aicommits.

# https://github.com/Nutlope/aicommits
npm install -g aicommits
# https://github.com/Nutlope/aicommits
npm install -g aicommits
# https://github.com/Nutlope/aicommits
npm install -g aicommits
# https://github.com/Nutlope/aicommits
npm install -g aicommits

Then we need a Open AI account to get an API key. After logging in or creating a free account, click on the profile popover on the top right or navigate to this link here.

Open AI profile popover
Open AI create API key
Open AI copy API key

Make sure you don't share your API key with others, or expose it in the browser or other client-side code. After copy the Open AI API key, paste in this command as so.

# To activate Open AI with AI Commits
export OPENAI_API_KEY=PASTE_IN_YOUR_OPEN_AI_KEY_HERE
# To activate Open AI with AI Commits
export OPENAI_API_KEY=PASTE_IN_YOUR_OPEN_AI_KEY_HERE
# To activate Open AI with AI Commits
export OPENAI_API_KEY=PASTE_IN_YOUR_OPEN_AI_KEY_HERE
# To activate Open AI with AI Commits
export OPENAI_API_KEY=PASTE_IN_YOUR_OPEN_AI_KEY_HERE

Now we are all set up. To use Commit AI, we need to git add all then run the following command in your git workflow:

# Example git workflow
git add .

aicommits
# ▲ Welcome to AICommits!
# ▲ Generating your AI commit message...

# ▲ Commit message: Update README with TODOs and additional resources.
# ? Would you like to use this commit message? (Y / n)
# Example git workflow
git add .

aicommits
# ▲ Welcome to AICommits!
# ▲ Generating your AI commit message...

# ▲ Commit message: Update README with TODOs and additional resources.
# ? Would you like to use this commit message? (Y / n)
# Example git workflow
git add .

aicommits
# ▲ Welcome to AICommits!
# ▲ Generating your AI commit message...

# ▲ Commit message: Update README with TODOs and additional resources.
# ? Would you like to use this commit message? (Y / n)
# Example git workflow
git add .

aicommits
# ▲ Welcome to AICommits!
# ▲ Generating your AI commit message...

# ▲ Commit message: Update README with TODOs and additional resources.
# ? Would you like to use this commit message? (Y / n)

There are compelling reasons to have good commit messages, especially when working in a team. Commit AI by Hassan El Mghari saves time in generating the perfect commit message.

The commit message for writing and creating this article is "Add files and setup Open AI for Commit AI blog post." How cool is that!

We're finally done writing commit messages.

Subscribe to my blog

I'd love to share my love for design, engineering, and thinking with you when my new articles are published.

You can unsubscribe at any time, no hard feelings.