1

When I run the command git branch -a I see a list of branches associated with a remote that no longer exists. ex:

remotes/does-not-exist/branch1 remotes/does-not-exist/branch2 remotes/origin/dev remotes/origin/feature3 

I want to remove the branches associated with does-not-exist from the list above. However if I run the command git remote prune does-not-exist I get the following error

conq: repository does not exist. fatal: Could not read from remote repository. 

How can I remove the branches associated with does-not-exist? Should I just delete the folder under .git/refs/remotes/?

1
  • For the time being, I "resolved" this issue by blowing away the local repo folder and cloning from the remote again. Commented Nov 5, 2015 at 20:52

4 Answers 4

4

I merged a branch to the master using the GitLab web page.

On my local shell, the branch was still present

git branch -a * 9-deploy master remotes/origin/9-deploy remotes/origin/HEAD -> origin/master remotes/origin/master 

Deleted the local branch with

git branch -d 9-deploy 

Deleted the reference to the remote branch with

git fetch -p 

Used the following reference to find commands

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

Comments

1

I had the same issue and was finally able to remove them using git branch -Dr does-not-exist/branch1.

Comments

0

You should remove the remote, not branches. By this the branches will be deleted too. git remote remove does-not-exist.

3 Comments

Thanks, @kan. I tried this, and perhaps I am just in a bad state, but this did not work for me.
I ran the command you provided, and then ran git branch -a again and I still saw the branches associated with the remote that no longer exists.
@AaronHoffman however, forced method to delete a reference is git update-ref -d remotes/does-not-exist/branch1.
0

To delete remote branches, I run git push origin --delete <branch>. So in your case, you may run the following:

git push does-not-exist --delete branch1 git push does-not-exist --delete branch2 

I hope this helps.

2 Comments

Thanks, @dlstadther, however this is not working for me. The remote itself no longer exists, so attempting to delete the remote branch also does not exist. I get the same error as git remote prune above.
@AaronHoffman Have you found this post?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.