0

Sometimes I have a few versions of the same features on other branches which has very similar names. How can I remove all local branches which are not on remote repo?

A little example: My local branches:

feature/authorization

feature/authorization-2

feature/authorization-with-error

Remote repo branches:

feature/authorization-2

And I want to have only local branch which is on remote repo: feature/authorization-2

programmer
  • 550
  • 2
  • 4
  • 25
  • Does this answer your question? [How can I delete all Git branches which have been merged?](https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged) – KennetsuR Feb 04 '21 at 09:09

1 Answers1

0
git branch --merged

you can skip some important branches

git branch --merged| egrep -v "(^\*|master|main|dev|skip_branch_name)"
KennetsuR
  • 704
  • 8
  • 17