Github CLI Extension for tidying your Git workspace!
gh tidy
does several things:
- Checks out master/main and pulls the latest from remote origin
- Runs 'git gc' to clean up unnecessary files & optimize your local repo
- Checks your local branches for ones that show as merged to master, and asks for your permission to delete them
- Checks your local branches for ones that have their corresponding pull requests merged, and asks for your permission to delete them
- If flagged, rebases all your local branches to the latest master
gh extension install HaywardMorihara/gh-tidy
gh extension upgrade HaywardMorihara/gh-tidy
Simply run
gh tidy
and it will checkout master/main, pull the latest, and clean up branches for you (with your permission, of course).
If your repo doesn't have a master/main branch, you can specify your trunk branch with the --trunk <branchname>
parameter
If you get an error such as:
failed to run extension: fork/exec <USER_PATH>/.local/share/gh/extensions/gh-tidy/gh-tidy: permission denied
then try:
gh extension upgrade HaywardMorihara/gh-tidy
This was the result of file permissions being ignored by Git. I fixed this in the repo with:
git config core.fileMode true
See here for more details.