Jerome Palayoor

Contact

AutoGit

A tiny CLI tool that adds, commits, and pushes in one command, for quick saves without typing the full git workflow.

How it works

The whole script is just eight lines. It calls out to git directly, the same commands that would be typed by hand, just chained together.

import subprocess
import sys
subprocess.call(["git", "add", "."])
if len(sys.argv) > 1:
    subprocess.call(["git", "commit", "-m", f"{sys.argv[1]}"])
else:
    subprocess.call(["git", "commit", "-m", "'updated stuff'"])
subprocess.call(["git", "push", "origin", "main"])

sys.argv is how it reads whatever you typed after the command. If you run autogit "fixed the bug", that string becomes the commit message. If you just run autogit with nothing after it, it falls back to a generic 'updated stuff' message instead.

Turning it into a real command

Running a Python script normally means typing python autogit.py every time. Packaging it with PyInstaller turns it into a standalone .exe, and dropping that into a folder that's on your system's PATH means you can just type autogit from any terminal, in any folder, like it's a real installed command.

pip install pyinstaller
python -m PyInstaller --onefile --windowed --icon=image.ico autogit.py

--onefile bundles everything into a single .exe instead of a folder of dependencies, --windowed stops a console window from popping up when it runs.

Contact Me