6

Possible Duplicate:
How do I delete a Git branch both locally and in Github?

First of all, I read how to remove a branch, but for some reason is not working on my project: https://github.com/ralcr/sdk.ralcr

When you first enter here you see some files 10 months old in a gh-pages branch. I have no idea how this branch was created and why it's displayed first, but I want to remove it and this is not working

Balutas-MacBook-Pro:sdk.ralcr Cristi$ git push origin --delete gh-pages
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

I want only the master branch.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Cristi Băluță
  • 1,295
  • 15
  • 27

3 Answers3

4

I found the solution here: https://github.com/matthew-brett/pydagogue/blob/master/gh_delete_master.rst I couldn't delete the branch because was the default branch. To change it go to Admin and there's a drop down for that.

Cristi Băluță
  • 1,295
  • 15
  • 27
3

To delete a remote branch, you must do it like so:

git push <remote> :<branch>
# example
git push origin :gh-pages

But in your case, origin don't seem to be a remote repo. You should checkout your remote name and use the good one.

git remote

Also, make sure your remote URL is writable one. Using the git protocol is read only, and so you'll need to pickup the ssh one. (should also work with the https url)

Simon Boudrias
  • 42,953
  • 16
  • 99
  • 134
  • ls-remote gives me this. Balutas-MacBook-Pro:sdk.ralcr Cristi$ git ls-remote From git@github.com:ralcr/sdk.ralcr.git 75e1db961aa1d2377e6f7c35542d7ee3a53712a0 HEAD 75e1db961aa1d2377e6f7c35542d7ee3a53712a0 refs/heads/gh-pages 8edf43d1bb60646c5c2f2026bae8c229763d5f98 refs/heads/master – Cristi Băluță Oct 08 '12 at 19:32
  • Oh sorry, it's just `git remote`. `ls-remote` is to list remote branches, tags, and other refs. (edited) – Simon Boudrias Oct 08 '12 at 19:35
  • Ok, git remote gives me something else: ralcr – Cristi Băluță Oct 08 '12 at 19:40
  • But still not working: Balutas-MacBook-Pro:sdk.ralcr Cristi$ git push ralcr :gh-pages remote: error: refusing to delete the current branch: refs/heads/gh-pages To git@github.com:ralcr/sdk.ralcr.git ! [remote rejected] gh-pages (deletion of the current branch prohibited) error: failed to push some refs to 'git@github.com:ralcr/sdk.ralcr.git' – Cristi Băluță Oct 08 '12 at 19:41
  • Oh, you should check out you use a writable url/protocol on your remote if `.git/config` (`git://` protocol is read only). If this is good, then you should checkout you really have write access to your repo. Is it your own? – Simon Boudrias Oct 08 '12 at 19:50
  • Thanks for the clues, it was not the url either, but you helped me find the solution, i'm posting it right now. – Cristi Băluță Oct 08 '12 at 20:12
2

Try using git branch -d <feature-branch>, it should let you delete a feature branch.

(though normally git merge <branch-name> is called before that to merge the branch before deleting it)

To delete the branch on remote:

git push origin :<feature-branch>
K Z
  • 29,661
  • 8
  • 73
  • 78