git: pruning / removing old branches: "error: failed to push some refs"
by Drone4four from LinuxQuestions.org on (#50998)
Here is a list of some remote branches on my GitHub repo:
Quote:
My intention / goal here is to delete all the ones which start with: 'remotes' (but not the two 'masters').
When I attempt to delete them, I get:
Quote:
So I Google 'error: unable to delete remote ref does not exist' which turns up a SO question/answer titled "Git says remote ref does not exist when I delete remote branch".
Another guide I found (which includes similar advice but consolidated into a single helpful blog post) can be found here.
These two guides recommend using commands such as these:
Quote:
In my case these commands helped me eliminate many of my old obsolete branches that I no longer need however these commands won't delete the remaining branches (listed above). Inputting these commands (and including some variations) produces the following output:
Quote:
So my primary question for all of you is: How do I delete `remotes/bridgent/Rayom-generator-app` and all similar remote branches?
It's also worth noting that when I replace `origin` with `remote`, I get similar output but what is different here is that remotes refer to the former git project's name (which no longer exists):
Quote:


Quote:
$ git branch -a warning: ignoring broken ref refs/remotes/remote/HEAD * master origin restoration-effort2 remotes/origin/master remotes/remote/master remotes/remote/carousel remotes/bridgent/animate remotes/bridgent/enlarged-hover remotes/bridgent/master remotes/bridgent/Rayom-generator-app remotes/bridgent/scripts remotes/bridgent/bridgent-carousel |
My intention / goal here is to delete all the ones which start with: 'remotes' (but not the two 'masters').
When I attempt to delete them, I get:
Quote:
error: unable to delete 'remote/bridgent-carousel': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<project_name>.git' |
So I Google 'error: unable to delete remote ref does not exist' which turns up a SO question/answer titled "Git says remote ref does not exist when I delete remote branch".
Another guide I found (which includes similar advice but consolidated into a single helpful blog post) can be found here.
These two guides recommend using commands such as these:
Quote:
$ git push origin --delete remotes/Rayom/animate $ git fetch --prune $ git push origin --delete <branch_name> |
In my case these commands helped me eliminate many of my old obsolete branches that I no longer need however these commands won't delete the remaining branches (listed above). Inputting these commands (and including some variations) produces the following output:
Quote:
$ git push origin --delete bridgent/Rayom-generator-app error: unable to delete 'bridgent/Rayom-generator-app': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<project_name>.git' $ git push origin --delete remote/bridgent-carousel error: unable to delete 'remote/bridgent-carousel': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<project_name>.git' $ git push origin --delete Rayom-generator-app error: unable to delete 'Rayom-generator-app': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<project_name>.git' $ git push origin :Rayom-generator-app error: unable to delete 'Rayom-generator-app': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<project_name>.git' $ git branch --remote <no output> $ git remote prune origin --dry-run <no output> $ git remote prune origin <no output> |
So my primary question for all of you is: How do I delete `remotes/bridgent/Rayom-generator-app` and all similar remote branches?
It's also worth noting that when I replace `origin` with `remote`, I get similar output but what is different here is that remotes refer to the former git project's name (which no longer exists):
Quote:
$ git push remote --delete bridgent/Rayom-generator-app error: unable to delete 'bridgent/Rayom-generator-app': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<**former**_project_name>.git' $ git push remote --delete remote/bridgent-carousel error: unable to delete 'remote/bridgent-carousel': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<**former**_project_name>.git' $ git push remote :Rayom-generator-app error: unable to delete 'Rayom-generator-app': remote ref does not exist error: failed to push some refs to 'git@github.com:Nostrad/<**former**_project_name>.git' |