Building a program can be a very tiring and time-consuming task. Deleting branches that have been merged into the main is inevitable.
Let’s discuss the steps required to delete branches that have been merged.
Deleting branches that have been merged is an easy task. You can do this in your command prompt, terminal (for mac users), or Git bash.
Note: Git Bash is an application for Microsoft Windows environments that provides an emulation layer for a Git command line experience.
Below are the steps to delete Git branches that have been merged:
git branch --merged
git branch --merged | grep -i -v -E "master|important"| xargs git branch -d
Note: The grep sequence contains the branches we do not want to delete. The code above excludes the master and any branches that contain importance in its name.
We can run the git branch
to check all the branches that remain.
Free Resources