All the commits in this repo are done with OpenCommit — look into the commits to see how OpenCommit works. Emoji and long commit description text is configurable.
-
Install OpenCommit globally to use in any repository:
npm install -g opencommit
-
Get your API key from OpenAI. Make sure you add payment details, so API works.
-
Set the key to OpenCommit config:
opencommit config set OPENAI_API_KEY=<your_api_key>
Your api key is stored locally in
~/.opencommit
config file.
You can call OpenCommit directly to generate a commit message for your staged changes:
git add <files...>
opencommit
You can also use the oc
shortcut:
git add <files...>
oc
GitMoji convention is used.
To add emoji:
oc config set emoji=true
To remove emoji:
oc config set emoji=false
To add descriptions:
oc config set description=true
To remove description:
oc config set description=false
You can set OpenCommit as Git prepare-commit-msg
hook. Hook integrates with you IDE Source Control and allows you edit the message before commit.
To set the hook:
oc hook set
To unset the hook:
oc hook unset
To use the hook:
git add <files...>
git commit
Or follow the process of your IDE Source Control feature, when it calls git commit
command — OpenCommit will integrate into the flow.
You pay for your own requests to OpenAI API. OpenCommit uses ChatGPT official model, that is ~10x times cheaper than GPT-3 and ~6x times cheaper than GPT-4.