Remove local git branches deleted remotely
Zhenguo Zhang
Bioinformatics scientist dedicated to healthcare innovation, fueled by diverse skills and a commitment to lifelong learning
Often, a git branch is deleted in github repo after merging it into main branch. However, such deleted branch may still exist in your local machine.
To show all the branches in your local machine, do the following
git branch -a
And you may see something like
* master
remotes/origin/HEAD -> origin/master
remotes/origin/feature/vennDiagram
remotes/origin/master
And the branches starting with `remotes/` are the local cache of remote branches.
To remove the branches whose linked remote branches have been deleted, run
git fetch -p
and it will clean these branches.