DEV Community

Cover image for How to delete multiple git branches locally and remotely?
Martins Gouveia
Martins Gouveia

Posted on

How to delete multiple git branches locally and remotely?

To delete multiple Git branches locally, you can use the following command in the terminal:

git branch -d branch1 branch2 branch3
Enter fullscreen mode Exit fullscreen mode

This will delete the locally specified branches. If any branches have not been merged, you will need to use -D instead of -d to force the deletion.

To delete the same branches remotely, you can use:

git push origin --delete branch1 branch2 branch3
Enter fullscreen mode Exit fullscreen mode

Make sure to replace "branch1", "branch2" and "branch3" with the actual names of your branches. This removes branches both locally and in the remote repository.

Top comments (0)