From 37e8e7b7544b2c733b92ce5137525448f6db16e7 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:45:33 -0400 Subject: [PATCH] add new bash function to prune git branches --- .config/bash/.bash_profile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/bash/.bash_profile b/.config/bash/.bash_profile index 208d0cc..5de5131 100644 --- a/.config/bash/.bash_profile +++ b/.config/bash/.bash_profile @@ -78,6 +78,12 @@ parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } +# delete local branches that don't exists in remote repository +git-prune() { + git fetch --prune + git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs git branch -d +} + # Set prompt color_prompt=yes