Susan Potter
git:

How do I delete a branch in Git locally and globally?

To delete a Git branch locally and then remotely, you can follow these steps:

  1. Delete the local branch using the git branch command with the -d option:

    git branch -d <branch_name>
    

    This will delete the local branch named <branch_name>. If the branch has unmerged changes, Git will not allow you to delete the branch. In that case, you can use the -D option instead of -d to force delete the branch.

  2. Delete the remote branch using the git push command with the --delete option:

    git push origin --delete <branch_name>
    

    This will delete the remote branch named <branch_name> on the origin remote.

Note: If you don’t want to delete the remote branch, you can skip step 2.

If you’re using a different remote name, replace origin with the name of your remote. Once you have deleted the branch locally and remotely, it will no longer be available in your Git repository.

If you enjoyed this content, please consider sharing via social media, following my accounts, or subscribing to the RSS feed.

If you are interested in low cost shared hosting with SSH access and Git repositories, I can recommend Hostinger which I use too (if you click on the link I will get a commission). You can use the coupon code BUSINESS10 to get 10% off the longer term Business plans (the one I chose too).