Delete and restore branches
You cannot delete the branch currently checked out. Switch to another branch first.
Delete a local branch
-d performs a safety check and refuses to delete a branch with unmerged commits. Use -D only when you intentionally want to discard those commits.
Delete a remote branch
This deletes the branch on the remote named origin; it does not delete your local branch.
Restore a branch that still exists remotely
Restore a deleted local branch
If the branch was deleted locally but its commits still exist, use the reflog:
Choose the commit where the branch pointed before deletion. Reflog entries are local and eventually expire, so recover important work promptly.
Remote deletion is not a backup
A deleted remote branch may be difficult to recover for everyone. Confirm the branch is merged or no longer needed before deleting it.