Bulk Delete Git branch

Source: Internet
Author: User

This post consists of: http://xinpure.com/?p=15

Bulk Delete Git branch

When you use git , you often find that you create a large number of branches unconsciously. So, the trouble is coming, so many abandoned branches, what to do?

You can't always do git branch-d branchname Delete it!

Here's a way to bulk delete a branch:

git branch |grep ‘branchName‘ |xargs git branch -D

This is the ability to bulk delete branches through Shell pipeline commands

git branch output current Branch list

grep is a match for the output of git branch , and the matching value is of course branchname

The role of Xargs is to convert the argument list to small pieces to pass to other commands

Therefore, the meaning of this command is:

从分支列表中匹配到指定分支,然后一个一个(分成小块)传递给删除分支的命令,最后进行删除。

This is where we want to bulk delete the branch.

Bulk Delete Git branch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.