Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/justinrubek/git-prune-branches

A command-line application that cleans local git branches from remote repositories
https://github.com/justinrubek/git-prune-branches

flake git gitoxide gix nix nix-flake rust

Last synced: 6 days ago
JSON representation

A command-line application that cleans local git branches from remote repositories

Awesome Lists containing this project

README

        

# git-prune-branches

This is a utility that you can use to delete all local git branches that have been deleted from a remote.
The tool will look at the local branches that track a remote branch and delete any that are no longer present on the remote.

## usage

- to delete local branches that track `origin`: `git prune-branches`
- to perform a dry run: `git prune-branches --dry-run`
- help page: `git prune-branches -h`
- to target a different remote: `git prune-branches --remote `
- to target a repository in another directory: `git prune-branches --path `

## why use this

There are many different ways to delete local branches that have been deleted from a remote.
However, remembering them and using them correctly can be non-trivial.
Here is one example of how you can do this using the command line:
`git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D`.
This command is not easy to understand or remember.
Additionally, cross-platform compatibility can be an issue.