Open Cyberbeni opened 3 years ago
Well... I think we should never remove any things automatically.
However, you can easily recognize such branches on the sidebar (they have warning icon), select them (hold CMD for multi-selection) and remove at once.
I mean as an added option for fetch. And it shouldn't force delete anything, only if the remote is also deleted and you don't have any changes on that branch that haven't been pushed. Google search shows that other people also have the same need: https://www.google.com/search?q=git+fetch+--prune+local
This is what I use currently in my zsh script:
for branchToDelete in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do
local commitHash=$(git rev-parse $branchToDelete)
if [[ "$(git branch -r --contains $commitHash)" == "" ]]; then
echo "\e[33mWarning:\e[0m '$branchToDelete' is not available on the remote, keeping it"
else
# Need to force delete in case it's merged into a different branch
git branch -q -D "$branchToDelete"
fi
done
I'm evaluating Fork as an alternative to Sourcetree. This is pretty much the only feature I miss.
Just like how GitHub has an option to automatically delete branches after you merged them, it would be nice to have an option in Fork to delete the local version of these branches automatically when fetching if they don't have any newer commits locally.