Back to Writings
2023-05-20Developer Tools

Using OpenCommit to Automate and Improve Git Commit Messages

Using OpenCommit to Automate and Improve Git Commit Messages

Streamline your git workflow with AI-powered commit messages using OpenCommit, a tool that generates meaningful commits automatically.

Using OpenCommit to Automate and Improve Git Commit Messages

You're neck-deep in your latest code masterpiece, the creative juices are flowing, but then you have to pause, switch gears, and write a commit message. We've all been there. That's where OpenCommit comes in - a tool designed to streamline the git commit process using AI.

Installation

Getting started with OpenCommit is straightforward. Install it globally via npm:

npm install -g opencommit

Then configure your OpenAI API key:

opencommit config set OPENAI_API_KEY=<your_api_key>

The key is stored locally in ~/.opencommit, keeping your credentials secure.

Usage Workflow

The workflow is simple and integrates seamlessly into your existing git habits:

  1. Stage your changes with git add or git add .
  2. Run opencommit or the shorthand oc
  3. Review the AI-generated commit message
  4. Confirm or edit as needed

That's it! No more staring at your terminal trying to summarize your changes.

Customization Options

OpenCommit offers several configuration options to tailor the experience:

Model Selection

By default, OpenCommit uses GPT-3.5-turbo, which is approximately 15x cheaper than GPT-4. If you need more sophisticated commit messages, switch to GPT-4:

oc config set model=gpt-4

Add Emojis

Make your commit history more visual:

oc config set emoji=true

Include Descriptions

Add detailed descriptions to your commits:

oc config set description=true

Language Support

OpenCommit supports multiple languages. For example, to use German:

oc config set language=de

Why I Use It

As someone who values clean commit history but often gets caught up in the flow of coding, OpenCommit has been a game-changer. It generates contextually relevant messages that I'd probably write myself - just faster and without breaking my concentration.

Give it a try and see how it fits into your workflow. Your future self (and your teammates) will thank you for those meaningful commit messages.

Tags
GitAIProductivityOpenAI