Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git shows old deleted branches in zsh TAB completion

Tags:

git

zsh

I apologize if this is a duplicate, but I don't know if this is a git "feature" or zsh, but I have a TON of delete branches that have been deleted stored somewhere if I tab over.

enter image description here

I have tried prune and that appears to not be doing want I intend.

The only branches I have locally are:

master
development
fix/root-cleanup
like image 442
paulywill Avatar asked Mar 20 '19 01:03

paulywill


People also ask

Does git pull remove deleted branches?

This is because "git pull" does not remove remote tracking branches for branches deleted from remote repo.

How do I delete old branches in git?

The easiest way to delete local Git branches is to use the “git branch” command with the “-d” option. The “-d” option stands for “–delete” and it can be used whenever the branch you want to clean up is completely merged with your upstream branch.

What is git completion zsh?

fpath : The git-completion. zsh is a function file, not designed to be sourced like the bash script. This command appends the ~/. zsh directory onto the shell's function lookup list.

Should old git branches be deleted?

They're unnecessary. In most cases, branches, especially branches that were related to a pull request that has since been accepted, serve no purpose. They're clutter. They don't add any significant technical overhead, but they make it more difficult for humans to work with lists of branches in the repository.


2 Answers

Apparently, the autocomplete tab was showing all the names of remote branches I had not done housekeeping on.

Found clues reading this blog post.

I was fixated on local and did not even consider if the plugin was pulling from the remote branches.

What's frustrating is that as in the screenshot all the branches without origin/ were not local and not there. As soon as I started to delete the remote branches these ones disappeared as well.

like image 120
paulywill Avatar answered Nov 16 '22 22:11

paulywill


Maybe installing a oh-my-zsh plugin like diazod/git-prune would help apply the various git prune aliases.

That in turn should reduce the number of branches considerably.


Note that, with Git 2.28 (Q3 2020), "git prune" has been added to the completion (in contrib/), which could be typed by end-users from the command line.

See commit 81120a9 (22 Jun 2020) by John Lin (johnlinp).
(Merged by Junio C Hamano -- gitster -- in commit 65ffaca, 06 Jul 2020)

bash-completion: add git-prune into bash completion

Signed-off-by: John Lin

Sometimes git would suggest the user to run git prune when there are too many unreachable loose objects.
It's more user-friendly if we add git prune into bash completion.

like image 23
VonC Avatar answered Nov 16 '22 22:11

VonC