2

I want to clean my local branches (merged or not), except master and develop.

I did some cleanup on the remote repository and I want to have the same locally.

I tried git fetch --prune which removed some, but there is still a large amount (over a hundred...).

1
  • What about push develop and master, clean the remote and do a new clone ? Commented Dec 3, 2021 at 9:57

1 Answer 1

4

I'm not aware of a way to do this in git out of the box, but this can done with some shell scripting:

git branch | grep -v master | grep -v develop | xargs git branch -D 

Just make sure you are checked out to master or develop before you start, or this script will also attempt to drop the branch you're currently checked out to (and fail to do so, of course).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.