Remove local git branches deleted remotely

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.

要查看或添加评论,请登录

Zhenguo Zhang的更多文章

社区洞察

其他会员也浏览了