This script (remove.mjs) helps you delete Git branches locally or remotely. Before using the script, please ensure that you have zx installed globally on your system.
-
zx: Install
zxglobally using the following command:npm install -g zx
-
Clone the Git repository or download the script (
remove.mjs) to your local system. -
Run the script using
zxin your repository's root directory. For example:cd my-project zx /path/to/remove.mjs
The script supports the following options:
-
--remote: Use this flag to delete remote branches instead of local branches. For example:zx /path/to/remove.mjs --remote
-
--exclude: You can exclude specific branches from deletion, by default the script will not delete themain, master, develop, development, and testbranches. For example:zx /path/to/remove.mjs --exclude=feature-x,bugfix-y
-
Certain branches (
main,master,develop,development, andtest) are considered permanent and will not be deleted to prevent accidental removal of important branches. -
Attempting to delete the
mainbranch will result in an error message, and the script will terminate to protect against accidental deletion.
Feel free to use and modify this script to suit your specific requirements. If you encounter any issues or have suggestions for improvements, please create an issue or submit a pull request on GitHub.
Happy branching and coding! 😄