Reputation: 3634
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
Upvotes: 0
Views: 3301
Reputation: 730
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
Upvotes: 0
Reputation: 10901
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
Upvotes: 3