Skip to content
/ push Public

Cross-platform utility to auto push all changes with git and optionally use AI to generate a commit message

License

Notifications You must be signed in to change notification settings

bakatz/push

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Push 🚀

Never write a commit message again.

by @ben_makes_stuff

Buy me a coffee

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.

Requirements

  • Git: Ensure you have Git installed and initialized in your project.

Quick Start

  1. Download the binary for your platform here: https://github.com/bakatz/push/releases
  2. 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 like ship): alias push="/path/to/download/dir/push-darwin-arm64"
  3. 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

Interactive Mode

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

Example Output

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.

Overview

The utility will perform the following steps:

  1. Add all changes using git add ..
  2. Generate a commit message based on the changes using OpenAI's GPT model (if available) or use the default message 🚀.
  3. Commit the changes with the generated message.
  4. If you passed -i, allow you to edit the commit message that was just generated.
  5. Push the changes to the remote repository.

Build Requirements

  • Go: This utility is written in Go. Ensure you have Go installed.

How to Build

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

Troubleshooting

  • 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.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Feel free to customize and extend this utility!

About

Cross-platform utility to auto push all changes with git and optionally use AI to generate a commit message

Resources

License

Stars

Watchers

Forks

Packages

No packages published