To Nha Notes | Dec. 20, 2023, 1:45 p.m.
The minimum supported version of Node.js is the latest v14. Check your Node.js version with node --version.
Install aicommits:
npm install -g aicommits
Retrieve your API key from OpenAI
Note: If you haven't already, you'll have to create an account and set up billing.
Set the key so aicommits can use it:
aicommits config set OPENAI_KEY=<your token>
This will create a .aicommits file in your home directory.
Check the installed version with:
aicommits --version
If it's not the latest version, run:
npm update -g aicommits
You can call aicommits directly to generate a commit message for your staged changes:
git add <files...> aicommits
aicommits passes down unknown flags to git commit, so you can pass in commit flags.
For example, you can stage all changes in tracked files with as you commit:
aicommits --all # or -a
👉 Tip: Use the aic alias if aicommits is too long for you.
Sometimes the recommended commit message isn't the best so you want it to generate a few to pick from. You can generate multiple commit messages at once by passing in the --generate <i> flag, where 'i' is the number of generated messages:
aicommits --generate <i> # or -g <i>
Warning: this uses more tokens, meaning it costs more