git-trim is a command-line utility that helps keep Git working directories clear of stale local branches.
It analyses tracking branches against their upstream and base branches, identifying branches that have already been merged, branches whose upstream has disappeared, and cases where a remote branch can also be removed after a merge.
The tool is intended as a safer companion to git fetch --prune. While Git’s prune operation removes remote-tracking references, git-trim also deals with the corresponding local tracking branches, avoiding the need for fragile shell one-liners or repeated manual branch deletion after pull requests have been merged or closed.
This is free and open source software.
Key Features
- Detects local tracking branches whose upstream branches have been merged or removed.
- Provides a dry-run mode so users can review the branches that would be deleted.
- Supports common merge styles including merge commits, fast-forward merges, rebase merges, and squash merges.
- Can remove forgotten remote branches when configured to do so.
- Supports GitHub flow, git-flow, simple workflows, and triangular workflows.
- Runs checks in parallel, helping with repositories that contain many stale branches.
- Offers configurable base branches, protected branch patterns, confirmation behaviour, and update intervals.
- Cross-platform support – runs under Linux, macOS, and Windows.
Website: github.com/foriequal0/git-trim
Support:
Developer: SeongChan Lee
License: MIT License

git-trim is written in Rust. Learn Rust with our recommended free books and free tutorials.
Related Software
| Git Storage and Security Tools | |
|---|---|
| git-lfs | Git extension for versioning large files |
| Jujutsu | Powerful version control system for software projects |
| git-bug | Distributed offline-first bug tracker |
| Dash | Rich terminal UI for GitHub |
| git-secrets | Prevent adding secrets into git repositories |
| Commitizen | Create well-structured Git commit messages |
| git-repair | Repair various forms of damage to git repositories |
| git-secret | Bash tool which stores private data inside a git repo |
| git-annex | Manage files with git without checking the file contents into git |
| gitmoji-cli | Use gitmojis in Git commit messages |
| ghq | Organise local clones of remote repositories |
| git-crypt | Transparent file encryption in git |
| gita | Manage multiple git repos |
| git-chglog | CHANGELOG generator implemented in Go |
| cz-git | Commitizen adapter and command-line tool |
| gitpane | Multi-repo Git workspace dashboard |
| git-trim | Keep Git working directories clear of stale local branches |
| gfold | Keep track of multiple Git repositories |
| Garden | Command runner and multi-repo Git configuration tool |
| mani | Manage collections of Git repositories |
| GitSocial | Git-native cross-forge collaboration |
| git-fresh | Refresh Git working copies from the terminal |
| Forge Sparks | Get Git forges notifications |
| gohome | Git standup and activity reporting CLI |
| git-appraise | Distributed code review system for Git repositories |
Read our verdict in the software roundup.
Explore our carefully curated directory of recommended free and open source software, covering every major software category.The directory forms part of our extensive collection of articles for Linux enthusiasts. It includes hundreds of detailed reviews, together with free and open source alternatives to proprietary software from companies such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. LinuxLinks also covers interesting projects worth exploring, Linux-compatible hardware, free programming books and tutorials, and much more. Know a useful free and open source Linux application that we haven’t covered? Tell us about it using our submission form. |


Please read our Comment Policy before commenting.