glab-tool
v1.0.1
Published
A CLI tool to clean up invalid GitLab branches
Readme
glbc - GitLab Branch Cleaner
A CLI tool to clean up invalid GitLab branches.
Installation
npm install -g glbcUsage
Global Options
--config <file>: Configuration file path (default:.glabrc)
Commands
glab clean
Clean up GitLab branches from merge requests targeting a specific branch.
glab clean --target mainOptions:
--target <branch>: Target branch to filter merge requests (default: main)--force: Force delete protected branches-d, --dry-run: Show what would be deleted without actually deleting
glab list
List all GitLab branches.
glab listConfiguration
Create a .glabrc file in your project root or home directory with the following format:
gitlab_url=https://gitlab.example.com/api/v4
gitlab_token=your_access_token
project_id=your_project_idOr set environment variables:
export GITLAB_URL=https://gitlab.example.com/api/v4
export GITLAB_TOKEN=your_access_token
export PROJECT_ID=your_project_idExamples
Clean branches from merge requests targeting the main branch:
glab clean --target mainForce delete protected branches:
glab clean --target main --forceDry run to see what would be deleted:
glab clean --target main --dry-runInteractive selection with inquirer (with numbered list):
glab clean
# Use arrow keys to navigate and space to select branches
# Items are numbered for easy identificationPerformance optimization note:
- API now filters merge requests by target branch directly
- Only includes opened and merged MRs (excludes closed MRs)
- Shows MR status in selection list
- More efficient for repositories with many merge requests
