Thursday, November 27, 2025

How to Delete Branch

  

Delete branch locally:

 

# If you're on the branch, first switch to another (e.g., master/main)

git checkout master or git checkout main

 

# Delete local branch

git branch -d branch_name    # safe delete (won't delete if unmerged)

git branch -D branch_name    # force delete (even if unmerged)



Delete branch from remote:

 

git push origin --delete branch_name

 


 Thank you.

No comments:

Post a Comment

How to Safely Reset Your Local Git Branch to Match the Remote

  How to Safely Reset Your Local Git Branch to Match the Remote Sometimes, your local Git branch contains commits that are already present i...