This document provides a high-level introduction to git-merged-branches, a command-line tool for identifying and managing Git branches that have been merged into a base branch. This overview covers the tool's purpose, core capabilities, architectural design, and execution workflow.
For detailed usage instructions, see the User Guide. For technical implementation details, see Architecture. For development and contribution guidelines, see Development.
Sources: package.json1-5 README.md1-9
git-merged-branches is a Node.js CLI application that analyzes local Git repositories to identify branches that have been fully merged into a base branch (typically master or main). The tool provides two primary capabilities:
--delete flag.The tool is distributed as an npm package and can be invoked using either the full command name git-merged-branches or the shorter alias gmb.
Sources: package.json2-5 package.json26-29 README.md8-9
| Capability | Description | Configuration |
|---|---|---|
| Branch Detection | Identifies local branches merged into the base branch (master or main). | Automatic detection README.md29-30 |
| Issue URL Formatting | Generates clickable links to JIRA, GitHub, or other issue trackers. | package.json config README.md56-79 |
| Automated Deletion | Deletes merged branches locally and remotely with the --delete flag. | Command-line option README.md41-52 |
| Flexible Configuration | Supports multiple issue prefixes and custom URL formats. | git-merged-branches key README.md56-79 |
The tool reads configuration from the user's project package.json under the git-merged-branches key, enabling per-project customization of issue tracker integration.
Sources: README.md29-52 README.md56-79 package.json20-25
The following diagram shows the complete system structure, mapping high-level concepts to specific code entities and their relationships.
Sources: package.json26-29 README.md56-79
The following diagram traces the complete execution path from user invocation through Git operations to console output.
Sources: README.md34-52 CHANGELOG.md62 CHANGELOG.md84
The tool automatically detects the base branch by checking for the existence of master or main. If neither exists, the tool notifies the user.
Sources: README.md29-30
A branch is considered "merged" if it is reported as merged by Git and is not on the same commit as the base branch (to avoid false positives).
Sources: CHANGELOG.md108
The tool supports both JIRA-style (prefix included in URL) and GitHub-style (prefix omitted in URL) patterns.
| Pattern Type | URL Format Example | Prefix Example | Use Case |
|---|---|---|---|
| JIRA-style | .../{{prefix}}{{id}} | ["TOKEN-"] | Prefix in URL |
| GitHub-style | .../issues/{{id}} | ["#"] | Prefix not in URL |
Sources: README.md58-79 CHANGELOG.md35
With the --delete flag, the tool performs a two-stage deletion:
git branch -dgit push origin --delete (only if the remote branch exists).Sources: README.md41-52 CHANGELOG.md84
The tool reads configuration from the user's package.json file. The configuration schema maps to the internal GitMergedConfig interface.
Sources: README.md56-79 package.json26-29
| Requirement | Value | Source |
|---|---|---|
| Node.js Version | >= 22.18.0 | package.json36 |
| Package Manager | pnpm@10.34.1 | package.json10 |
| Module System | ES Modules (type: "module") | package.json3 |
| Build Output | dist/index.mjs | package.json27-28 |
| License | MIT | package.json11 |
Sources: package.json3-37 CHANGELOG.md10
The package is distributed via npm and provides two primary execution methods:
Global Installation:
npx Execution:
The compiled output is located at dist/index.mjs and is configured as the binary entry point for both git-merged-branches and gmb.
Sources: README.md13-25 package.json26-29
Refresh this wiki