How to delete the Git branch locally and remotely?+How do I delete a Git branch locally and remotely?+delete a Git branch locally and remotely?
ReportPlease briefly explain why you feel this question should be reported .
Delete the git remote branch
git push <<origin>> --delete <branch_name> # Git version 1.7.0 or newer
git push <<origin>> -d <branch_name> # Git Shorter version (Git 1.7.0 or newer)
git push <<origin>> :<branch_name> # Git versions older than 1.7.0
Delete the git remote master branch
$ git push -d <remote_name> <new_name_of_branch>
$ git push -u origin <new_name_of_branch>
$ git branch -d <branch_name>
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
$ git branch -a
Example
$ git push -d master main
$ git push -u origin main
Easier way to achieve
$ git push <remote_name> :<new_branch_name>
Delete the git local branch
$ git branch -d branch_name
or
$ git branch -D branch_name
If we use -D then, it is to be force deleting the branch without checking merged status)
Leave an answer