2

I accidentally created a branch called "remotes/origin/remotes/origin/aclark" and can't delete it with:

git branch -d remotes/origin/remotes/origin/aclark

Git says:

error: branch 'remotes/origin/remotes/origin/aclark' not found.

I tried some of the suggestions here: Deleting a badly named git branch, but they are geared more towards bad branch names that start with "--".

Is there any way an end user can delete this branch or do I need a git admin? (The branch in question lives at gitorious).

Thanks

Alex

1

1 Answer 1

11

This is a remote branch, so you need to delete it on the server. To do that, you need to push an empty reference.

$ git push origin :remotes/origin/aclark 

Note, the syntax of the git push command is:

$ git push <remote> <local-reference>:<remote-branch-name> 

So in the case, we are pushing an empty reference, and the remote name is the name of the branch we want to destroy. In your case, the branch name "remotes/origin/remotes/origin/aclark" indicates that it is a remote branch on the remote server name "origin", and the name on the distant server is "remotes/origin/aclark".

The other client will need to issue the following commands to have the branch removed from their local repository (if they fetched when the invalid branch existed):

$ git fetch origin $ git remote prune origin 

More information can be found in the git-push and git-remote manpages.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! This has just begun to sink in. And indeed, git push origin :remotes/origin/aclark did the trick. Thanks again!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.