If you have a git branch that you have pushed upstream to the remote origin and want to delete both this local and the remote branch, you can follow the below two commands,
Step 1: Delete Git Local Branch
Make use of the git branch command with --delete flag,
Command:git branch --delete <branch-name>
You can also make use of the shorthand version -d
Example:git branch -d <branch-name>
If the branch is not merged then you would also need to make use of the --force or -f flag.
Example:git branch -d -f <branch-name>
The above command, we can use -D instead of -f and -d
git branch -D <branch-name>

Step 2: Delete Git Remote Branch
To delete the remote branch you would need to make use of the git push origin followed by -d or --delete flag and the branch name,
Command:git push origin --delete <branch-name>
or,
git push origin -d <branch-name>

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!