Git Cleaner VS Code Extension
This VS Code extension provides a convenient way to clean up local Git branches that no longer exist on the remote repository.
Features
- Status Bar Icon: A trashcan icon labeled "Git Clean" appears in the VS Code status bar. Clicking this icon executes the cleanup command.
- Command Palette Integration: You can also run the cleanup command from the VS Code Command Palette by searching for "Git Cleaner: Clean Gone Branches".
Requirements
- Bash: This extension requires bash to be available in your system:
- Linux/macOS: Bash is usually pre-installed
- Windows: You need to install one of the following:
Installation
- Clone the repository (or download the source code) into a directory on your machine.
- Open VS Code.
- Go to the Extensions view (
Ctrl+Shift+X
or Cmd+Shift+X
).
- Click on the
...
(More Actions) menu in the top right of the Extensions view.
- Select
Install from VSIX...
.
- Navigate to the directory where you cloned/downloaded the extension, and select the
.vsix
file (you'll need to package it first, see "Usage for Development").
Usage
Once installed and activated:
- Click the "Git Clean" icon in the VS Code status bar (usually at the bottom left).
- Alternatively, open the Command Palette (
Ctrl+Shift+P
or Cmd+Shift+P
) and type Git Cleaner: Clean Gone Branches
and press Enter.
The extension will then:
- Fetch and prune your remote branches (
git fetch --prune
).
- Identify local branches that are marked as
gone
.
- Delete these
gone
local branches.
Output and any errors will be shown in a VS Code information message.
Usage for Development
If you want to develop or test this extension:
Clone the repository:
git clone https://gitlab.com/poprygun/vsx-git-clean.git
cd vsx-git-clean
Install dependencies:
pnpm i
Run the extension in Development Host:
- Open the project in VS Code.
- Press
F5
to open a new Extension Development Host window. The extension will be active in this new window.
Package the extension (to create a .vsix file):
pnpm build
(You might need to answer Yes
to the question first time)
Continuous Integration
This project uses GitLab CI for automated testing, building, and deployment:
- Testing: Runs linting and tests on every commit
- Building: Creates a packaged VSIX file for distribution
- Deployment: Publishes the extension to the VS Code Marketplace when changes are pushed to the main branch
To set up deployment, you need to configure the following in your GitLab project:
- Add a CI/CD variable named
VSCE_PAT
with your Visual Studio Marketplace Personal Access Token
- The deployment job is set to manual trigger by default for safety
For more information on obtaining a PAT, see the VS Code Publishing Extensions documentation.
Changelog
Version 0.0.4
- Added check for bash availability on Windows
- Added clear error message when bash is not found
- Updated documentation with Windows requirements
- Added custom extension icon
- Converted SVG icons to PNG format for better compatibility
Version 0.0.3 and earlier
- Initial implementation with bash support
Contributing
Feel free to open issues or submit pull requests if you have suggestions or find bugs.
License
This project is licensed under the MIT License - see the file for details.