alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

How do I delete a Git branch?

How do I delete a Git branch?

It's very easy:

To delete the remote branch

 git push -d origin <branch-name> 

Or

 git push origin :<branch-name> 

-- You can also delete tags with this syntax

To forcefully delete the local branch

 git branch -D <branch-name> 

Note: do a git fetch --all --prune on other machines after deleting remote branch, to remove obsolete tracking branches.

Example

to remove the local branch

 git branch -D my-local-branch 

to remove the remote branch

 git push origin :my-remote-branch 

TIP: if you want to see all available branches you can use git branch -a,

and to see just remote branches, you can use git branch -r


79 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online