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>

-
Have Questions? Post them here!
More Posts related to Git,
- [Fixed] Git Clone git@github.com: Permission denied (publickey) Could not read from remote repository Fatal error
- Github: How to Invite Collaborators
- Git Commit - Author identity unknown, Please tell me who you are email
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- [fix] zsh: command not found: git
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021
- Get List of all local branches git command
- Git Revision Questions Before the Interview
- git fatal: Authentication failed error [fix]
- How to Install Git on Ubuntu Linux
- GitHub: How to Search Code
- How to change Git Default Author and Committer details in Eclipse
- How to check your installed version of Git
- Install GitHub Command Line Tool on Mac
- How to Merge Branch into Master Branch
- Perform an Empty Commit in Git without anything in Staging Area
- Git Fix: fatal: refusing to merge unrelated histories Error
- How to undo last Git Commit on Local Repository?
- git command to remove/unstage files from staging area
- Step-by-Step: Setting up Docker + Ubuntu Linux + Git + GitHub Tutorial
- Remove git config at Local, Global or System Levels?
- Fix [oh-my-zsh] Cant update: not a git repository
- Git Config Command - A Deep Dive
- fatal: Unable to create '/c/git_repo/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.
- How to change directory in Git bash
More Posts:
- How to get UTC (GMT) time using JavaScript - JavaScript
- [IRCTC] Indian railways official eRail API 1.1 for developers to get train info - HowTos
- 10 Beginners Commands for macOS Terminal Usage - MacOS
- How to get weather details in Command Prompt, macOS or Linux Terminal - HowTos
- [Java Threads] Should we extend Thread Class or implement Runnable interface - Java
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required. - MacOS
- List of Programming Languages Supported by Notepad++ - NotepadPlusPlus
- Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience - Java