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?


Please 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
$ 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
$ git branch -D branch_name

If we use -D then, it is to be force deleting the branch without checking merged status)

Manimaran Samuthirapandi 4 months 2021-10-05T08:47:52+02:00 0 Answers 2 views 0

Leave an answer

Captcha Click on image to update the captcha .