Remove Branches CLI is a simple tool to help you remove local Git branches that no longer exist on the remote repository.
I created this tool out of a personal need. I was tired of the repetitive process of manually checking and deleting local branches that had already been removed from the remote repository. This tool automates that process, making branch management much simpler and more efficient.
While it is possible to achieve the same result with a simple script, I have recently fallen in love with Golang. Therefore, I decided to take this opportunity to create Remove Branches CLI in Golang.
To install the this on Linux or macOS, open your terminal and run the following command:
curl -sSL https://raw.githubusercontent.com/lukaszgasior/remove-branches/main/install.sh | bash
Tool will be installed in /usr/local/bin
folder
To install this tool on Windows, open PowerShell as Administrator and run the following command:
iex "& { $(Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/lukaszgasior/remove-branches/main/install.ps1' -UseBasicParsing) }"
The app will be installed in "$env:ProgramFiles\Git\cmd"
folder, so in case of any issues with running this command
make sure this folder is added to your $PATH.
After installing the tool, you can use it with the following commands:
To display local branches that no longer exist on the remote repository, run:
git remove-branches
To remove local branches that no longer exist on the remote repository using the -d flag, run:
git remove-branches --prune
To force remove local branches that no longer exist on the remote repository using the -D flag, run:
git remove-branches --prune --force
Just run:
go build -o git-remove-branches . && mv git-remove-branches $GOPATH/bin/
goreleaser release --snapshot --clean
If you find any issues or have suggestions for improvements, please open an issue or create a pull request on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for more details.