Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

How to delete remote branch (e.g. Github) from command line? [duplicate]

I have a git repository in my local machine:
I add a new branch called test and add a few commits
Then I checkout to master branch and add commits to it.
So I use git push --all github and continue working on master. After some time I decide to completely remove the test branch and use: git branch -d test and git branch -r -d github/test, but it only deletes the local branch used for tracking the actual test branch as git says:

Deleted remote-tracking branch github/buggy (was acc5a58).

I'm asking if there's a way to actually remove the test branch from github servers from command-line?

Answer

Cancel
4
  • 2
    git push origin :remote_branch
    – ut9081
    Aug 5, 2020 at 14:18
  • 1
    For the deleting local branch, the delete flag should be uppercase. Like this git branch -D local_branch
    – Edgar256
    Jul 29, 2021 at 2:39
  • Thanks for pointing it out. Updated! Jul 30, 2021 at 18:44
  • git push origin :remote_branch only works if you've deleted the local branch. The answer as posted is better, since it treats the two cases independently. Feb 23 at 19:25