DEV Community

Cover image for AI generated git commit messages

AI generated git commit messages

Brian Douglas on March 03, 2023

Over my decorated 10-year career in development, I have seen some of the worst commit messages. I don't blame the developer on this either, because...
Collapse
 
drhyde profile image
David Cantrell

I don't blame the developer on this either, because it is hard to remember what you just did at the time of the git commit.

git commit -v really helps here. Since I started enforcing it on myself (through use of a shell function that intercepts all my attempts to run git) my commit messages have got much better.

Collapse
 
vhoyer profile image
Vinícius Hoyer

git add --patch|-p has helped a lot in this also, both tools we all should be using, actually

Collapse
 
jcolag profile image
John Colagioia (he/him)

I have to walk a fine line, in this response, because...

  1. I love the technical challenge and want to encourage that sort of thing, but
  2. The premise seems horrifying and will generate ill-will from colleagues.

First, if you don't remember what work you did, then you probably put too much into your commits. While I realize that nobody's perfect and things slip through the cracks, each commit should do a specific thing, and someone can ideally add a specific feature (and nothing else) by cherry-picking other otherwise moving a defined set of commits.

Then, changes (in a professional environment) should all be connected to a ticket, so that people can track the work happening without analyzing the repository. Commits should call out the relevant ticket numbers and probably echo the language used in the ticket. I'm never going to search a repository for "the time that Zemzem removed a text box." I want "the work done on ticket #4586, ideally seeing the individual tasks involved in finishing that ticket."

Finally, you're allowed to use a graphical interface, when you commit, and look at the changes that you're committing. Again, if you did a bunch of things at once, you should probably use such a tool, so that you can commit specific lines that go together, instead of full files.

Again, that doesn't take away from the technical achievement or the entertainment value. And (like anything with generative AI) if you use the results as a springboard to what you'll really write, that'll probably serve you better. But I definitely worry about trying to "outsource" communication with your closest colleagues...

Collapse
 
aiocean profile image
AI Ocean

Look like developers have the sam idea, I also did the same thing with you. But i named it ai-commit instead. Use conversation form to ajust the message

Collapse
 
bdougieyo profile image
Brian Douglas

Please drop a link if its open source. Also to be clear this isn't my project, but a project open sourced by @nutlope

Collapse
 
eamodio profile image
Eric Amodio

If you use VS Code the latest pre-release version of GitLens also provides the ability to use ChatGPT to generate commit messages (and probably soon to explain commits). There is even a setting so the user can control the commit message style as part of the prompt.

Collapse
 
adriens profile image
adriens

Adopted here ;-p

Collapse
 
thebrown profile image
Saleumsack

It's very nice, but sometimes I'm too lazy to think about the commit message after the long hour code.

Collapse
 
0vortex profile image
TED Vortex (Teodor Eugen Duțulescu)

the too many requests are killing my vibe tho :<

Collapse
 
k1lgor profile image
k1lgor

It's nice, I tested it yesterday, but please note that too many commits (requests) in a short period of time will result in an error 400 - bad request. 👏🔝🎉

Collapse
 
bdougieyo profile image
Brian Douglas

Good call out. There are some obvious areas of improvements and I think this project is set up well for some one to take what is already there and make something useful for a lot of people.

Collapse
 
bharat55566 profile image
Bharat

Nice one

Collapse
 
sevapp profile image
Vsevolod

Very simple and inspiring implementation. I'll probably do a couple of experiments too =)

Collapse
 
lackovic profile image
Marco Lackovic

Hey there, are you using the latest version of AI Commits? Commits with imperative mood have been merged two weeks ago (see this PR) and merged but your screenshots do not reflect that and still use the past tense.

Collapse
 
bdougieyo profile image
Brian Douglas

Screenshot is from the README.

Collapse
 
derappelt profile image
Simon Appelt

Funny Project.
But i don't think that's a good idea to send all you code/commits to OpenAi.
Pretty sure your boss/client will not appreciate that.
Probably it's also against your NDA. Be cautious.

Collapse
 
liamdawson7379 profile image
Liam Dawson

I really enjoyed reading your post about AI-generated git commit messages. As a developer myself, I can relate to the struggle of writing clear and informative commit messages. I think Nutlope/aicommits is a really interesting tool, and it's impressive to see how popular it has become in just two weeks.

I found it helpful that you took the time to explain how the AI part of the code works, and it's great to see how OpenAI is being used in practical applications. I agree with you that the createCompletion function is where the magic happens, and your comments on each line were very helpful in understanding what's going on.

I also appreciate that you shared your thoughts on the code and your experience with building CLIs. It's always great to hear from other developers and learn from their experiences.

Overall, I thought your post was well-written and informative. Thank you for sharing your insights and for encouraging others to contribute to open source projects. I look forward to reading more of your 30 days of OpenAI series, and I'll definitely check out Nutlope/aicommits!

Collapse
 
martinawaissma profile image
Martina Waissma

I have waited for this!

Collapse
 
tomhenry profile image
Tom Henry

Cool idea