git-tidy-python/README.md

1.8 KiB

git-tidy

I wrote this utility to save myself some repetitive typing, because I often come back to a repo after a while of not using it, and in the meanwhile a remote may have moved on or I'm not sure what state it's in.

So this gets it cleaned up relatively quickly.

It's more or less the equivalent of

git checkout main
git fetch --all --prune  # prune is to delete unnecessary remote refs
git merge origin/main main --ff-only
git branch --merged | grep -v main | xargs git branch -d

with some extra convenience and (I hope) safety features.

Using

The actual script is named git_tidy.py. After cloning, you can copy (or symlink) it to somewhere on your path (e.g. ~/bin/git-tidy).

Alternatively, you can use a package manager such as uv. My personal preference is this, as uv will place the tool on the PATH for you and you can get straight to using it.

uv tool install https://codeberg.org/james-smith-za/git-tidy-python.git

Then when you cd to your git repository, you can type

git tidy

and it'll do its thing! Only the Python standard library is used, no additional packages are required. I have tested (manually) with Python 3.8 through to 3.13, so I would imagine that future versions should work just fine.

Background

The repo is named with -python on the end because I have a vague ambition to redo this program in Go at some point, which will make it easier to distribute for people who don't have Python installed by default (i.e. Windows users). But I'm not sure when I'll get to that.

TODO

I'd like to actually get a set of unit-tests in place, but I'm not sure how to go about this really because there's a lot of subprocess calls. If anyone reads this and has an idea, I'd be glad to hear from you.