git-tidy

May 6, 2026 ยท View on GitHub

git-tidy is a zsh plugin command for safely reviewing and removing local branches whose upstream branch is marked [gone].

The default mode is a dry run, so it shows deletion candidates without changing the repository.

Installation

Source the plugin from your zsh configuration, or load it through your zsh plugin manager.

source /path/to/git-tidy/git-tidy.plugin.zsh

Usage

git-tidy              # dry run: list deletion candidates
git-tidy --run        # delete eligible [gone] branches
git-tidy --days=N     # protect branches with commits in the last N days (0 disables age protection)
git-tidy --no-fetch   # skip git fetch --prune before scanning
git-tidy --help|-h    # print command help

Aliases are provided for convenience:

gtidy   # git-tidy
gtidy!  # git-tidy --run

Completion

git-tidy registers tab completion only when zsh's completion system is already loaded. If you source the plugin manually and want completion, run autoload -Uz compinit && compinit before the source line, or let your zsh plugin manager handle completion initialization.

Safety rules

git-tidy skips or protects branches when they are:

  • the current branch
  • the detected base branch, such as main or master
  • checked out in another Git worktree
  • newer than the configured protection window

The protection window defaults to 7 days and can be changed with GIT_TIDY_PROTECT_DAYS or --days=N. Use --days=0 when you want to disable only the recent-commit age guard while keeping the other safety rules.

Notes

The command is intended for trunk-based workflows where feature branches are removed from the remote after merge, including squash-merge workflows where local branches may not be considered merged by Git.