Skip to content

Instantly share code, notes, and snippets.

View mser-om's full-sized avatar

Mike mser-om

View GitHub Profile
@mser-om
mser-om / git-pfetch
Created June 15, 2023 22:57
Git Pfetch command
#!/bin/bash
# This command does a git fetch, determines which branches on the remote have been removed, and clear them out of
# your local repository. This is best performed when the `main` or `master` branch is currently checked out.
# Place this file in /usr/local/bin (e.g. /usr/local/bin/git-pfetch) and mark as executable. Then simply use
# it at the command line like you would any other git subcommand: `git pfetch`. Enjoy a cleaner workspace!
git fetch -p && for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do git branch -D $branch; done