43

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?

Masked Man
  • 2,176
  • 2
  • 22
  • 41
  • 1
    A answer already answers your question: http://stackoverflow.com/questions/2003505/how-to-delete-a-git-branch-both-locally-and-remotely – GWilkinson Oct 04 '16 at 13:08
  • @GSkidmore, yes and thanks. I haven't found that post in my previous searches and had to ask my own. `:)` – Masked Man Oct 04 '16 at 13:11

3 Answers3

68

Local Branch

git branch -D local_branch

Remote Branch

git push origin --delete remote_branch
Mihir Patel
  • 2,202
  • 3
  • 23
  • 36
37

As with every git server:

$ git push github :<BRANCH_NAME>

or:

$ git push github --delete <BRANCH_NAME>

Example:

$ git push github --delete test
Arkadiusz Drabczyk
  • 11,227
  • 2
  • 25
  • 38
2

Use this command:

git push github :test

Read "push nothing as refname test on github remote"

blue112
  • 52,634
  • 3
  • 45
  • 54