How to Delete current git branch in Visual Studio Code

If you’re sure the existing branch is no longer required, you can delete it.

To delete current Current branch from Visual Studio Code, First we need to checkout / Switch from that branch to other / main branch.

Example:
git checkout main

For Example, the name of the branch that we need to delete is “test”, we need to use the following command to delete this branch.

git branch -d test

It will delete the branch test

If Git refuses because the branch has unmerged changes, then use the following command.

git branch -D main

⚠️ Warning: The -D option permanently deletes the branch, including commits that are not reachable from another branch. Use it carefully.