How to delete a Git branch locally and remotely?

To delete a Git branch locally and remotely, you can follow the steps below:

  1. Delete the branch locally:

    git branch -d branch_name

    Replace branch_name with the name of the branch you want to delete.

  2. Delete the branch remotely:

    git push origin --delete branch_name

    Again, replace branch_name with the name of the branch you want to delete.

  3. Verify the branch has been deleted remotely:

    git branch -r

    This will list all the remote branches, and the branch you deleted should no longer appear.

Keep in mind that only users with necessary permission can delete branches from a remote repository.