Never write a commit message again.
Longer explanation: this utility automates the process of committing and pushing code changes to your Git repository. It generates a commit message based on the changes using OpenAI's gpt-4o-mini
model or falls back to "🚀" if no API key is provided.
- Git: Ensure you have Git installed and initialized in your project.
- Download the binary for your platform here: https://github.com/bakatz/push/releases
- Then add it as an alias (replace darwin-arm64 with your computer's os and cpu architecture, and if desired replace
push
with something else likeship
):alias push="/path/to/download/dir/push-darwin-arm64"
- You're done! Just run
push
to start using it.
Optionally: if you want to use OpenAI for generating commit messages, make sure you set your environment variable like this before running the above steps:
export OPENAI_API_KEY=your-openai-api-key
push
also supports interactive mode to allow you to make changes to the commit messages generated by this tool. Just pass -i
like this: push -i
and you will be able to edit the commit message using git's default editor before the changes are pushed.
If you want to change the default editor to something else, run this command before using push
:
git config --global core.editor <editor binary path>
For example, to change the editor to nano
, use this command:
git config --global core.editor nano
Running command: git add .
Running command: git diff --staged
Generated commit message:
Refactored function to improve readability
Running command: git commit -m "Refactored function to improve readability"
Commit successful. Output:
[main 1f4e9d4] Refactored function to improve readability
1 file changed, 3 insertions(+), 1 deletion(-)
Running command: git push
Push successful. Output:
To https://github.com/your-username/your-repo.git
1f4e9d4..a1b2c3d main -> main
Changes committed and pushed successfully.
The utility will perform the following steps:
- Add all changes using
git add .
. - Generate a commit message based on the changes using OpenAI's GPT model (if available) or use the default message
🚀
. - Commit the changes with the generated message.
- If you passed
-i
, allow you to edit the commit message that was just generated. - Push the changes to the remote repository.
- Go: This utility is written in Go. Ensure you have Go installed.
To build the utility, you need Golang installed (latest version from https://go.dev). Then simply run the following command:
make
This will compile the Go code and generate a bunch of cross-platform executables in the build
directory.
Example binary path:
./build/push-darwin-arm64
- OpenAI API Key Not Set: If the API key is not set, the utility will use the default commit message
🚀
. - Git Errors: If there are issues with committing or pushing, ensure your Git setup is correct, and that you have the necessary permissions.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to customize and extend this utility!