di-sukharev / opencommit
- четверг, 30 марта 2023 г. в 00:14:29
GPT CLI to auto-generate impressive commits in 1 second 🤯 🔫
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 opencommitGet 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...>
opencommitYou can also use the oc shortcut:
git add <files...>
ocGitMoji convention is used.
To add emoji:
oc config set emoji=trueTo remove emoji:
oc config set emoji=falseTo add descriptions:
oc config set description=trueTo remove description:
oc config set description=falseTo specify the language used to generate commit messages:
# de, German ,Deutsch
oc config set language=de
oc config set language=German
oc config set language=Deutsch
# fr, French, française
oc config set language=fr
oc config set language=French
oc config set language=françaiseThe default language set is English
All available languages are currently listed in the i18n folder
The opencommit or oc commands can be used in place of the git commit -m "${generatedMessage}" command. This means that any regular flags that are used with the git commit command will also be applied when using opencommit or oc.
oc --no-verifyis translated to :
git commit -m "${generatedMessage}" --no-verifyYou can ignore files from submission to OpenAI by creating a .opencommitignore file. For example:
path/to/large-asset.zip
**/*.jpg
This is useful for preventing opencommit from uploading artifacts and large files.
By default, opencommit ignores files matching: *-lock.* and *.lock
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 setTo unset the hook:
oc hook unsetTo use the hook:
git add <files...>
git commitOr 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.