Sometimes or after a while, during a project, merged branches become too much to display or to manage, to prevent this, lets say garbage, developers should delete some of them out locally or remotely. This script will help all developers who has git repositories for their projects to clean 'git brach' or 'git branch --all' or 'git branch (repo_name)' outputs.
So simple, in the downloaded directory untar the ball, go into the coming up directory then type the following. that script will copy the main one into local/bin directory.
$ bash install.sh
To delete blah1 and blah2 branch from local;...
$ gitclear -local -D blah1 blah2
...or to delete all branches except blah1 and blah2 from local;
$ gitclear -local -E blah1 blah2
... from test repo itself as an example;
$ gitclear -remote -D blah1 blah2
The output will be as following, confirmation will be prevent unwanted actions. if user type y
then action will be continue as deletion operation otherwise passed
will be displayed.
blah1 branch will be deleted from the test repo
Continue (y/n)? _
To write all branches down is hard then developers can use regex alternative as following as an example; to delete local numerically named branches
$ gitclear -local -D ^[0-9]+$
... Regex could be typed wrong, to prevent this unfortunate mistake, questioned all actions as following screen will be displayed for previously given example, to be sure that action exactly what developers want...
1123 branch will be deleted from local
Continue (y/n) ? _
... If the answer is y
then action will be deletion otherwise the string, passed
, will be displayed, just for info.