How to Delete a Branch using Git Command?

By Hardik Savani April 23, 2022 Category : Git

In this tutorial we will go over the demonstration of how to delete a branch using git command. This article goes in detailed on git remove branch from local. This article will give you simple example of git remove branch from remote. This article goes in detailed on git remove branch from local only.

In this tutorial, we will use git branch command delete branch locally and remote in github repository. we will use git command to delete branch name into github. so let's follow below step to remove branch in git.

Clone Git Repository(Optional):

If you are new and you haven't create or clone github repository yet then you can follow bellow tutorial:

Github Create or Clone Git Repository.

Delete Branch using Git Command:

I will give you two commands to delete git branch from local and remote. let's see one by one command:

Delete Git Branch from Local:

Delete git branch from local means the branch will only remove on your local machine not on github repository. so it will stay on github repository.

Example:

git branch -d dev-change

You can see below layout:

Delete Git Branch from Remote:

Delete git branch from remote means the branch will only remove on github repository. so it will remove branch from github repository.

Example:

git push --delete origin dev-change

You can see below layout:

I hope it can help you...

Tags :
Shares