git-merged
v1.0.1
Published
Find Git branches that have been merged into production/main branch
Maintainers
Readme
git-merged
🔍 Find Git branches that have been merged into your main/production branch.
A simple, fast CLI tool to identify branches that are safe to delete because they've already been merged into your target branch.
Installation
Install globally via npm:
npm install -g git-mergedUsage
Basic Usage
# Find remote branches merged into origin/main
git-merged
# Find branches merged into production
git-merged production
# Find branches merged into develop
git-merged developOptions
git-merged [branch-name] [options]Arguments:
branch-name- Target branch to check merges into (default:main)
Options:
-l, --local- Search local branches instead of remote-r, --remote- Search remote branches (default)-n, --no-file- Don't save to file, only display in console-o, --output PATH- Custom output file path--delete-remote- Delete found remote branches fromorigin--delete-local- Delete found local branches--skip-confirm- Delete without interactive confirmation--author NAME- Only include branches whose last commit author containsNAME-h, --help- Show help message
Examples
Find remote branches merged into origin/main
git-mergedFind local branches merged into develop
git-merged develop --localDisplay results without saving to file
git-merged main --no-fileSave to custom location
git-merged main --output ~/reports/merged-branches.txtCombined options
git-merged production --local --output ./report.txtDelete merged remote branches
git-merged main --delete-remoteDelete merged local branches
git-merged main --delete-localDelete both local and remote branches for one author
git-merged main --delete-remote --delete-local --author radimbigDelete without confirmation
git-merged main --delete-remote --delete-local --skip-confirmWhen deleting without --skip-confirm, the tool prints the branches and the exact commands that will be executed, then asks for confirmation:
confirm deleting:
branch1 merged 21.01.2025 into origin/main
branch2 merged 22.05.2026 into main
commands that will be executed
git push origin --delete branch1
git branch -d branch2Output
The tool displays results grouped by author, showing:
- Merge Date - When the branch was merged
- Branch Name - Name of the merged branch
- Commit ID - Short hash of the merge commit
- Author - Who created the branch
Example output:
--- Branches Merged into 'origin/main' (Mode: remote) ---
=== Author: John Doe ===
Merge Date Branch Name Commit ID
---------- ----------- ---------
2024-02-10 feature/user-authentication a1b2c3d
2024-02-08 bugfix/login-error e4f5g6h
=== Author: Jane Smith ===
Merge Date Branch Name Commit ID
---------- ----------- ---------
2024-02-12 feature/dashboard-redesign i7j8k9lRequirements
- Git must be installed and available in PATH
- Must be run from within a Git repository
- For remote mode, requires access to
originremote
How It Works
The tool:
- Fetches the latest data from remote (if in remote mode)
- Lists all branches merged into the target branch
- Identifies actual merge commits (excludes fast-forwards and squashes)
- Extracts merge date, author, and commit information
- Groups results by author and sorts by date
Notes
- The tool only identifies branches merged via explicit merge commits
- Fast-forwarded or squashed branches are excluded (their "merge date" cannot be reliably determined)
- By default, results are saved to
deletable_branches_report.txtin the current directory
Development
PowerShell Version
The original PowerShell version is still available as find-deletable-branches.ps1 for Windows users who prefer PowerShell.
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Issues
Found a bug or have a feature request? Please open an issue on GitHub.
