Remove Git Branches

Hydroid
May 6, 2022

--

Remove git branches locally.

After working on your project for some time, you end up with a lot of branches on your local which are not needed any more and you have to scroll and find the branch which you need.

To Remove a Git Branch :

git branch -D <branch_name>

To Remove All Git Branches Except Master:

Removing the branches one by one is a exhausting job. I have a trick for you that will make your life easier:

git branch | grep -v “master” | xargs git branch -D

Note:

  • grep -> Used to search for a string of characters, -v -> to remove a string
  • xargs -> Reads streams of data from standard input, then generates and executes command lines

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Hydroid
Hydroid

Written by Hydroid

Currently working as a Full Stack Developer in India

No responses yet

Write a response