Skip to content
Programming101
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

Learn everything about programming

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

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes