⚠️ Warning: Don’t do this for production code. This is for side projects where I rely on AI-generated code. I only use it on feature branches, not main/deploy branches.
I got tired of the git add, git commit -m "...", git push dance. So I set up a one-liner called git ship:
git config --global alias.ship '!f(){ git add -A && oco && git push; }; f'
Now I just run git ship and it:
- Stages all changes
- Generates a commit message using AI
- Pushes to the current branch
The magic is OpenCommit (oco), which looks at your diff and writes a reasonable commit message.
#Local setup with Ollama
I didn’t want to hit OpenAI’s API for every commit, so I pointed it at a local Ollama instance:
# Install OpenCommit
npm i -g opencommit
# Configure to use local Ollama with llama3.2
oco config set OCO_AI_PROVIDER='ollama' OCO_MODEL='llama3.2'
oco config set OCO_API_URL=http://127.0.0.1:11434/api/chat
Make sure Ollama is running locally with the model pulled:
ollama run llama3.2
Note for Mac users: If you see
ECONNREFUSED ::1:11434, it’s an IPv6 issue. Ollama listens on IPv4 (127.0.0.1), but Node resolveslocalhostto IPv6 (::1) first on macOS.Fix: Use
127.0.0.1instead oflocalhostinOCO_API_URL. Also ensureOCO_API_URLis just the base URL—OpenCommit appends its own paths.
That’s it. Fast, free, and offline-capable. I use it dozens of times a day now for side projects.
