Delete a Git branch locally and remotely

To delete a Git branch locally, you can use the git branch command with the -d option:

ruby

$ git branch -d branch_name

Replace branch_name with the name of the branch you want to delete. This will delete the branch locally on your machine.

To delete a Git branch remotely, you need to use the git push command with the --delete option:

perl

$ git push origin --delete branch_name

Replace branch_name with the name of the branch you want to delete, and origin with the name of your remote repository. This will delete the branch from the remote repository.

It’s important to note that you can only delete a branch that has been fully merged into another branch. If the branch you’re trying to delete has not been fully merged, you’ll need to merge it into another branch before you can delete it.