Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/justinrubek/git-prune-branches
- Owner: justinrubek
- Created: 2024-03-31T22:27:52.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-12-07T02:44:18.000Z (about 1 month ago)
- Last Synced: 2025-01-01T15:39:23.548Z (9 days ago)
- Topics: flake, git, gitoxide, gix, nix, nix-flake, rust
- Language: Nix
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.