Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

Delete a git remote/local branch

YASH PAL, 14 July 202530 August 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 Branch

To 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 using

git push origin --delete <branchName>

To delete a local remote-tracking branch:

git branch --delete --remotes <remote>/<branch>
git branch -dr <remote>/<branch> # Shorter
git fetch <remote> --prune # Delete multiple obsolete tracking branches
git fetch <remote> -p # Shorter

To 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 dev

Deletes the branch named dev if its changes are merged with another branch and will not be lost. If the dev branch

does contain changes that have not yet been merged that would be lost, git branch -d will fail:

$ git branch -d dev

error: 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) by

using the -D flag:

$ git branch -D dev

Also read – How to become a computer expert

Developer Guide Tips & Tricks Developer guide

Post navigation

Previous post
Next post

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes