Delete a git remote/local branch YASH PAL, 14 July 202514 July 2025 Delete a git remote/local branch – In this article, we are going to learn about how to delete a git branch locally and remotely.Delete a Remote BranchTo delete a branch on the origin remote repository, you can use Git version 1.5.0 and newer.git push origin : <branchName>You can delete a remote branch usinggit push origin --delete <branchName>To delete a local remote-tracking branch: git branch --delete --remotes <remote>/<branch>git branch -dr <remote>/<branch> # Shortergit fetch <remote> --prune # Delete multiple obsolete tracking branchesgit fetch <remote> -p # ShorterTo delete a branch locally. Note that this will not delete the branch if it has any unmerged changes:git branch -d <branchName>To delete a branch, even if it has unmerged changes: git branch -D <branchName>Delete a branch locally$ git branch -d devDeletes the branch named dev if its changes are merged with another branch and will not be lost. If the dev branchdoes contain changes that have not yet been merged that would be lost, git branch -d will fail:$ git branch -d deverror: The branch ‘dev’ is not fully merged.If you are sure you want to delete it, run ‘git branch -D dev’.Per the warning message, you can force delete the branch (and lose any unmerged changes in that branch) byusing the -D flag:$ git branch -D devAlso read – How to become a computer expert Developer Guide Tips & Tricks Developer guide