Tell prj_name_ how to bang all local prj_name_ simultaneously with the prefix prj_name_

 $ git branch ... * prj_name prj_name_camera prj_name_defs ... 

I try

 v.malov$ git branch -D prj_name_* error: branch 'prj_name_*' not found. 
  • one
    I would probably print the names of the branches, copy the text, Ctrl + A, Ctrl + L into sublime, and bring in the sequence of names in the string. If this is not a one-time task, but it won't work for a script - Ali

2 answers 2

somewhere so

 for b in $(git branch | egrep "^prj_name_"); do git branch -D $b; done 

just before starting check the list of brunches for deletion

 git branch | egrep "^prj_name_" 

and if anything, adjust the regular schedule.

    First of all, you need to switch to some branch that you will not delete. Git will not remove the currently selected branch.

    Think about whether you want to delete branches that are not locked up? So you can lose unsaved changes. If you do not want, switch to the branch where the results should be loaded and use --merged :

     git checkout prj_name git branch --merged | egrep "^\s*prj_name_" 

    This is a list of branches to be deleted. In the regular schedule ^\s* denotes the beginning of the line and some whitespace characters. The beginning of the line eliminates all cases where prj_name is not a prefix, but the middle of the line. \s* necessary because the git branch command displays two spaces before the names of all branches except the current one (before it there will be *<пробел> )

    If the test result is correct, you can delete it.

     git branch --merged | egrep "^\s*prj_name_" | xargs git branch -d 

    If you want to delete, including non-contained branches, then:

     git branch | egrep "^\s*prj_name_" | xargs git branch -D