0

This is what I'm doing.... how do I get rid of the origin remote branch? And what is it?

[master] /dir: git status
# On branch master
nothing to commit (working directory clean)

[master] /dir: git remote show
github

[master] /dir: git branch -r
  github/master
  origin/HEAD -> origin/master

[master] /dir: git branch -rd origin/HEAD
error: remote branch 'origin/HEAD' not found.

[master] /dir: git branch -rd origin
error: remote branch 'origin' not found.

[master] /dir: git branch -rd origin/HEAD -> origin/master
-bash: origin/master: No such file or directory

[master] /Applications/MAMP/htdocs/asanawww: git branch -rd origin/master
error: remote branch 'origin/master' not found.

[master] /Applications/MAMP/htdocs/asanawww: git push origin :master
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

I also tried

git gc --prune=now

with no luck

Justin
  • 3,418
  • 3
  • 27
  • 37

3 Answers3

4

I'm sorry that I don't haven enough reputation to add a comment.

I realize it is really a comment rather than an answer, but this question may help.

The solution:

git remote set-head origin -d
Community
  • 1
  • 1
dyng
  • 2,854
  • 21
  • 24
3

You should do:

git branch -rd origin/master

Take into consideration that this command will delete the remote branch locally, that is the 'origin/master' reference that is kept in your repository. If that branch still exists in the remote the 'origin/master' reference will be created again when there is a pull or a fetch.

To properly delete it from the remote you can use:

git push origin :master

This <local>:<remote> notation means that the <local> reference will be pushed as the <remote> branch. By using :master you mean that "no reference" is to pushed as master, thus deleting it.

Yet another alternative is to do a delete push:

git push --delete origin master
Maic López Sáenz
  • 10,385
  • 4
  • 44
  • 57
  • Thanks for your help - I tried the commands above and they failed - I believe it's because the remote origin doesn't exist? error: remote branch 'origin/master' not found. fatal: 'origin' does not appear to be a git repository – Justin Jan 24 '13 at 17:48
0

Maybe you need to remove the work-tree associated with local branch (in case it was checked into another directory)

git worktree remove work-tree-directory --force //use force if its dirty

then you can delete the branch using

 git branch -D branch-to-delete  // -D is for force delete, for normal use -d
Muhammad
  • 720
  • 6
  • 13