DevOps | Cloud | Analytics | Open Source | Programming





How to Delete a Git Branch Remotely, Locally or from GitHub ?



In this post, we will see How to Delete a Git Branch Remotely, Locally or from GitHub. It is a good practice to keep the Git branches organized with no unnecessary add-ons. Essentially branches are named and movable references to commits done by Git users. Do note that when we delete a branch,  the commits are not deleted. There is a possibility of recovering the commits. But to reach those commits , you would require the hash of the last commit. So let's see the ways to delete a Git branch.

Option 1 : Delete a Git Branch Locally

To delete the branch locally use below steps -

  • First checkout the branches that you don't want to delete. Git does not permit to delete the branch that are currently in use.


git checkout main


  • Delete the branch next


git branch -d <the\_branch\_to\_be\_deleted>


Additional optional flags -

  • "d flag - This option will delete the branch only if it has already been pushed and merged with the remote branch.
  • "D" flag - This option will allow to force the branch to be deleted - even when the branch is been pushed or merged yet.
   

Option 2 : Delete a Git Branch Remotely

  • Use any of the below commands to delete a Git branch remotely. If you get error in the process , it is advisable to cross check if the branch exists or not(in case it is been deleted already).


git push <remote> --delete <the\_branch\_to\_be\_deleted>

git push <remote> :<the\_branch\_to\_be\_deleted>


  • Subsequently sync the branch listing using below command. We use the prune or "-p" flag.  Branches that don't exist on the remote, will be deleted.


git fetch -p


Option 3 : Delete a Git Branch from GitHub UI itself

  • You can also delete a branch directly in GitHub itself.
  • You can login to the GitHub and go to the main repo. Open the "Branches" Tab which lists all the current branches.
  • On the right hand side, you will see the delete icon to delete a branch.
  Hope this helps.  

Additional Read -



How to Delete a Git Branch ,how to delete a git branch locally ,how to delete a git branch locally and remotely ,how to delete a git branch remotely ,how to delete a git branch from github ,how to delete a git branch in gitlab ,how to delete a git branch from ui ,how to delete a git branch created locally ,how to delete a git branch in bitbucket ,how to delete git branch after merge ,how to delete git branch and remote ,how to delete the git branch in local ,how to delete all changes in git branch ,how to delete all files in git branch ,how to delete git branch ,how to delete git branch from local ,how to delete github repository ,how to delete github account ,how to delete git repository ,how to delete git branch from remote ,how to delete git stash ,how to delete gitlab repository ,how to delete git tag ,how to delete git branch in github ,delete a git branch azure devops ,delete a git branch ,delete a git branch locally ,delete a git repository ,delete a git branch locally and remotely ,delete a git tag ,delete a git commit ,delete a git repository locally ,delete a git project ,delete a git repository from github ,delete a git stash ,how to delete a file in a git branch ,how to delete a git branch both locally and remotely ,how to delete a local branch git bash ,how to delete remote branch git bash ,how to delete git branch from browser ,delete a branch remotely and locally ,how to remove a git branch locally and remotely ,how to delete a git branch command ,how to delete a remote branch git command ,how to delete local git branch command line ,how to delete a commit in git branch ,how to delete changes on a git branch ,how to delete a branch in git using cmd ,how to delete a branch git locally ,how to delete a default branch in git ,how do i delete a git branch ,how to delete branch in git desktop ,how do i delete a git branch locally and remotely ,how do i delete a git branch locally ,how to delete directory in git branch ,how to delete a branch in azure devops git ,how to delete a git branch from eclipse ,how to delete branch git extensions ,how to delete existing git branch ,how to delete a local branch in git eclipse ,how to delete a git branch from local ,how to delete a git branch from command line ,how to delete a git branch from remote ,how to delete a git branch from bitbucket ,git how to delete a git branch ,how to delete git branch from gui ,how to delete a branch in git using gui ,how to delete a branch in github using git bash ,github delete branch ,how to clear git branch history ,how to delete branch history in git ,how to delete a git branch in local ,how to delete a git branch in terminal ,how to delete a git branch in github ,how to delete a git branch in remote ,how to delete a git branch in eclipse ,how to delete a git branch in ui ,how to delete existing branch in git ,how to delete a branch in git ,how to delete created branch in git ,how to delete git branch command ,gitlab delete branch ,how to delete git local branch stackoverflow ,gitlab delete remote branch ,how to delete local git branch in intellij ,how to delete git master branch ,how to clear git master branch ,how to delete my git branch ,how to delete my local git branch ,how to delete a branch name in git ,how to delete a new branch in git ,how to delete a git branch on github ,how to delete a git branch on local ,how to delete a git branch on remote ,how to delete git branch on server ,how to delete git branch on bitbucket ,how to delete a branch on git ,how to delete git branch stack overflow ,how to delete a pushed branch in git ,how to delete a protected branch in git ,how to permanently delete git branch ,how to delete a git branch locally and remote ,how to delete git branch remote and local ,how to remove a file from git remote branch ,git delete remote branch ,how to delete git branch stackoverflow ,how to delete a branch in git sourcetree ,how to delete a branch in git stash ,how to delete branch git visual studio ,how to delete a sub branch in git ,how to delete a specific branch from git ,how to delete a branch git terminal ,how to delete a branch tortoise git ,how to delete a branch in tfs git ,how to delete local branch through git bash ,how-do-i-delete-a-git-branch-with-tortoisegit ,how to delete git branch using command ,how to delete a branch in git using visual studio ,how to delete a local branch using git ,how to delete a remote branch using git ,how to delete a branch in git using eclipse ,how to delete git branch in vscode ,how to delete a branch with git ,how to delete a branch in git website ,how to delete a local branch with git ,how to delete branch in git web ,can i delete a branch in git ,how to delete the branch in git ,how to delete a particular branch in git ,how do you delete a git branch ,how to delete your local git branch ,how delete a git branch ,how to delete the git branch locally ,how to delete local branch in git and pull again ,how to delete all local branch in git ,how to remove a branch in git locally ,how to delete local branch commit in git ,how to delete local branch in git desktop ,delete branch locally and remotely git ,how to delete local branch in git extensions ,how to delete a git branch from local and remote ,how to remove a file from git local branch ,how to delete local branch in git gui ,how to delete branch in git gui ,how to git delete local branch ,how to delete a branch locally in git bash ,how to delete a local branch in git visual studio ,how to delete local branch in git visual studio code ,how to delete my git local branch ,how to delete local master branch git ,git how to delete local branch only ,how to delete a branch locally using git ,how to delete a local branch using git bash ,how to delete local branch in git using eclipse ,how to delete local branch in git visual studio 2019 ,how to delete branch in remote git ,how to remove local and remote branch in git ,how to delete a branch locally and remotely in git ,how to delete a branch in git locally ,how to delete git origin branch ,how to delete a remote branch in git bash ,how to remove a remote branch git ,how to delete a remote branch git ,how to delete remote branch in git extensions ,how to git delete remote branch ,how to delete git branch from server ,how to delete a remote branch from git bash ,how to remove git branch from origin ,how to delete a remote feature branch in git ,github delete remote branch ,how to delete a file from remote branch in git ,how to delete a folder from remote branch in git ,how to delete a branch in remote repo in git ,




how to delete branch in remote repository in git ,how to remove a remote branch in git ,how to delete branch from github using git bash ,how to delete the branch from github ,how to delete a branch from git ,how to delete branch from github ,how to delete branch from github ui ,how to delete branch from git repository ,how to delete a local branch from git ,delete git branch from vs code ,git how to delete a branch from remote ,how to delete the branch in gitlab ,how to delete local branch in gitlab ,how to delete branch in gitlab using command line ,how to delete branch in gitlab ,how to delete git branch from gitlab ,how to delete branch gitlab remote ,delete git branch gitlab ,deleting a branch in gitlab ,how to delete a local branch in gitlab ,how to delete branch in gitlab ui ,how to delete branch in git from ui ,how to delete a repository in gitlab ,how to delete branch on local git ,how to delete locally created branch in git ,how to delete branch from local in git ,how to delete branch in local git ,how to remove a local branch git ,how to delete git branch on local ,how to delete a branch in local git ,how to delete branch in bitbucket using git bash ,how to delete a local branch in bitbucket ,how to delete created branch in bitbucket ,how to delete branch name in bitbucket ,bitbucket delete a branch after merge ,bitbucket remove branch after merge ,deleting branches in bitbucket ,how to delete a branch from bitbucket using git ,how to delete branch after merge github ,can i delete branch after merge ,should i delete git branch after merge ,will git merge delete branch ,does git merge delete branch ,github delete branch after merge automatically ,why delete branch after merge ,should i delete branch after merge ,how to delete branch without merging ,how to delete new branch in git ,how to delete any branch in git ,how to delete the feature branch in git ,git after merge delete branch ,how to delete the merge commit in git ,how to remove merge branch in git ,git delete branch after merge request ,git delete branch after squash merge ,how to delete an existing branch in git ,how to delete branch github remote ,how to delete a git branch remote ,how to delete a remote github branch ,how to delete remote branch git command ,how to delete git branch from local and remote ,how to delete git branch from remote ,how to delete git branches on remote ,how to delete branch from remote github ,how to delete git branch in remote ,how to delete branch local and remote in git ,how to remove git remote branch ,how to delete git branch on remote ,how to delete remote origin branch git ,how to delete git branch locally and remotely ,how to delete the local master branch in git ,how to delete local branch in git visual studio ,how to delete git branch local and remote ,how to delete local branch in git bash ,how to delete local branch in git eclipse ,how to delete git branch from local ,how to delete branch in local in git ,how to delete local branch in git linux ,can i delete local master branch ,how to delete local master branch ,how to delete a master branch in git ,can you delete master branch in git ,how to delete a branch in local git repository ,how to remove a local git repository ,how delete local git repository ,how to delete local branch in git terminal ,how to delete local branch in tortoise git ,how to delete branch in git terminal ,how to delete a local branch in terminal ,how to delete branch in git using terminal ,how to delete local branch in git using command ,how to delete local branch in visual studio code ,how to discard all changes in git branch ,how to remove local changes in git branch ,how to undo changes in git branch ,how to undo changes in git local branch ,how to discard all changes in a git branch ,how to discard all changes in git ,how to remove all changes in git branch ,how to delete all feature branches in git ,how to delete all changes in git ,delete changes in branch git ,delete all changes in git ,how to delete current branch in git ,how to delete all files in a branch github ,how to delete files in git branch ,how to remove files in git branch ,how to delete all files in a git branch ,how to delete a file in git branch ,how to remove all files from git branch ,how to delete all branches in git ,how to delete all files from git branch ,delete all files in a branch git ,how to delete all files from master branch git ,how to delete a folder in git branch ,restore deleted branch git azure devops ,delete a branch in azure devops ,delete a branch in azure repo ,delete branch from devops ,delete git repository azure devops ,delete branch in azure devops ,delete branch from azure devops ,delete git branch azure devops ,how to remove a file in git branch ,how to remove a file from remote git branch ,how to remove untracked files in git branch ,how to delete a file from git branch ,how to delete a file from a git branch ,how to remove a file from a git branch ,how to remove untracked files in git ,how to delete branch from git ,git delete branch both locally and remotely ,git remove branch both locally and remotely ,delete a branch both locally and remotely ,how to delete branch locally in git ,how to delete branch in git ,how to delete a local repo in git bash ,how to delete a branch git bash ,how to remove local changes in git bash ,how to remove local commit in git bash ,how to delete a directory in git bash ,how to delete a file in git bash ,delete all local branches git bash ,how to delete the branch in git bash ,how to delete branch using git bash ,how to delete a local branch in git command line ,how to delete branch in git bash ,how to delete a local branch from git bash ,how to delete a branch in git from terminal ,how to delete a local branch in git bash ,how to delete a branch in git bash ,how to delete the local branch in git ,how to delete a branch on git bash ,how to delete a branch through git bash ,how to delete a branch in git using terminal ,how to delete remote branch in git bash ,how to delete remote branch in git command ,how to delete a commit in git bash ,how to cancel a command in git bash ,how to delete remote branch from git bash ,how to delete a git branch from terminal ,how to delete a git repository from terminal ,how to delete a folder in git bash ,how to delete a branch in git from git bash ,how to delete remote branch on git ,git bash command to delete remote branch ,how to delete a line in git bash ,how to cancel a merge in git bash ,how to remove remote origin in git bash ,how to delete a project in git bash ,how to delete a repository in git bash ,how to delete a tag in git bash ,how to delete remote branch using git bash ,how to delete a branch using git bash ,how to delete remote and local branch in git ,how to delete branch from github browser ,how to delete a branch in git from browser ,how delete branch in git ,how to delete git branch from ui ,delete a branch from remote and local ,deleting a branch remotely ,delete branch in remote and local ,delete a branch remotely and locally git ,how to delete a branch remotely and locally ,delete a branch in remote and local ,delete a branch on local ,delete a branch locally and on remote ,delete a branch in remote ,remove git branch locally and remotely ,how to remove a branch locally and remotely ,how to remove a branch from local git ,how to remove a branch in local git ,how to remove a branch from remote git ,how to remove branch from local git ,how to remove branch in local git ,how to restore a deleted branch in git command line ,how to delete a branch in git command ,how to delete git branch command line ,how to delete the git branch ,how to delete git branch in command line ,how to delete a git branch command line ,how to delete the branch in git command ,how to delete a remote branch using git command ,how to delete branch github command line ,how to delete branch in github using command line ,how to delete branch git command ,how to delete a branch using git command ,how to delete a branch from remote in git ,how to delete the remote branch in git ,how to delete remote branch in git from command line ,how to delete a branch in remote repo ,how to delete a branch in git remote ,




How to Delete a Git Branch delete ,can i delete a branch in git ,can we delete a branch in git ,can you delete master branch in git ,delete a branch remotely and locally ,delete a git branch azure devops ,delete a git branch command ,delete a git branch local ,git delete remote branch ,git how to delete a branch from remote ,git how to delete a git branch ,git how to delete upstream branch ,git how to force delete a local branch ,github delete branch ,gitlab delete branch ,gitlab delete remote branch ,how delete a branch in git ,how delete a git branch ,how delete branch in git ,how do i delete a git branch ,how do i delete a git branch locally ,how do i delete a git branch locally and remotely ,how do i delete a remote branch in git ,how do you delete a git branch ,how to clear git branch history ,how to clear git master branch ,how to delete a branch created in git ,how to delete a branch from bitbucket using git ,how to delete a branch from local in git ,how to delete a branch git locally ,how to delete a branch git terminal ,how to delete a branch in azure devops git ,how to delete a branch in git ,how to delete a branch in git bash ,how to delete a branch in git command ,how to delete a branch in git eclipse ,how to delete a branch in git extensions ,how to delete a branch in git from browser ,how to delete a branch in git from ui ,how to delete a branch in git gui ,how to delete a branch in git locally ,how to delete a branch in git locally and remotely ,how to delete a branch in git server ,how to delete a branch in git sourcetree ,how to delete a branch in git stackoverflow ,how to delete a branch in git stash ,how to delete a branch in git terminal ,how to delete a branch in git ui ,how to delete a branch in git using cmd ,how to delete a branch in git using eclipse ,how to delete a branch in git using gui ,how to delete a branch in git using visual studio ,how to delete a branch in git visual studio ,how to delete a branch in git website ,how to delete a branch in github using git bash ,how to delete a branch in tfs git ,how to delete a branch in tortoise git ,how to delete a branch name in git ,how to delete a branch on git ,how to delete a branch tortoise git ,how to delete a branch using git ,how to delete a branch with git ,how to delete a checked out branch in git ,how to delete a commit from a branch in git ,how to delete a commit in git branch ,how to delete a default branch in git ,how to delete a feature branch in git ,how to delete a file from a branch in git ,how to delete a file from remote branch in git ,how to delete a file in a git branch ,how to delete a folder from remote branch in git ,how to delete a git branch ,how to delete a git branch both locally and remotely ,how to delete a git branch command ,how to delete a git branch created locally ,how to delete a git branch debian ,how to delete a git branch debug ,how to delete a git branch from bitbucket ,how to delete a git branch from command line ,how to delete a git branch from eclipse ,how to delete a git branch from github ,how to delete a git branch from local ,how to delete a git branch from remote ,how to delete a git branch from ui ,how to delete a git branch in bitbucket ,how to delete a git branch in eclipse ,how to delete a git branch in github ,how to delete a git branch in gitlab ,how to delete a git branch in local ,how to delete a git branch in remote ,how to delete a git branch in terminal ,how to delete a git branch in ui ,how to delete a git branch java ,how to delete a git branch jenkins ,how to delete a git branch job ,how to delete a git branch locally ,how to delete a git branch locally and remote ,how to delete a git branch locally and remotely ,how to delete a git branch mac ,how to delete a git branch master ,how to delete a git branch microsoft ,how to delete a git branch mongodb ,how to delete a git branch on github ,how to delete a git branch on local ,how to delete a git branch on remote ,how to delete a git branch remotely ,how to delete a git branch xargs ,how to delete a git branch xbox ,how to delete a git branch xcode ,how to delete a local branch git bash ,how to delete a local branch in git ,how to delete a local branch in git bash ,how to delete a local branch in git command line ,how to delete a local branch in git eclipse ,how to delete a local branch in git visual studio ,how to delete a local branch on git ,how to delete a local branch using git ,how to delete a local branch with git ,how to delete a master branch in git ,how to delete a new branch in git ,how to delete a newly created branch in git ,how to delete a particular branch in git ,how to delete a protected branch in git ,how to delete a pushed branch in git ,how to delete a remote branch git command ,how to delete a remote branch in git ,how to delete a remote branch on git ,how to delete a remote branch using git ,how to delete a specific branch from git ,how to delete a sub branch in git ,how to delete all branch in git ,how to delete all changes in git branch ,how to delete all files from a branch in git ,how to delete all files in git branch ,how to delete an existing branch in git ,how to delete any branch in git ,how to delete branch git extensions ,how to delete branch git visual studio ,how to delete branch history in git ,how to delete branch in git desktop ,how to delete branch in git using terminal ,how to delete branch in git web ,how to delete changes on a git branch ,how to delete contents of a branch in git ,how to delete created branch in git ,how to delete directory in git branch ,how to delete existing git branch ,how to delete git branch after merge ,how to delete git branch and remote ,how to delete git branch from browser ,how to delete git branch from gitlab ,how to delete git branch from gui ,how to delete git branch from server ,how to delete git branch in intellij ,how to delete git branch in vscode ,how to delete git branch on bitbucket ,how to delete git branch on server ,how to delete git branch remote and local ,how to delete git branch stack overflow ,how to delete git branch stackoverflow ,how to delete git branch using command ,how to delete git local branch stackoverflow ,how to delete git master branch ,how to delete local branch through git bash ,how to delete local git branch command line ,how to delete local git branch in intellij ,how to delete my git branch ,how to delete my local git branch ,how to delete new branch in git ,how to delete remote branch git bash ,how to delete the branch in git ,how to delete the git branch in local ,how to delete your local git branch ,how to force delete a branch in git ,how to force delete a remote branch in git ,how to permanently delete a branch in git ,how to permanently delete git branch ,how to remove a branch in git locally ,how to remove a file from git local branch ,how to remove a file from git remote branch ,how to remove a git branch locally and remotely ,how to remove a remote branch in git ,how to restore a deleted branch in git command line ,how to undo a git branch delete ,how-do-i-delete-a-git-branch-with-tortoisegit