In the local repository I see the following picture:

| | * <branch_name> origin/<branch_name> | 

On the server (bitbakt) this branch is gone and long ago.

 git push origin :<branch_name> 

logically gives out

 remote ref doesn't exist 

How can I delete a local link to a non-existing branch already deleted?

  • 3
    git fetch --prune? - Duck Learns to Take Cover
  • Issue as an answer. Partially helped, deleted a part of the branches that no longer exist on the server. Part left. The remaining branches are removed - delete. Although they, too, are already gone. Very strange behavior of the beatback. - Mira
  • it does not remove locale brunches, they need to be pushed out - Duck Learns to Hide
  • It’s clear about locale branches, it’s about links, origin / branch_name for remote branches of which are really not there anymore. The part deletes with a delete, but the remaining part is --prune. For some reason he considers only some branches deleted not existing, although on the server I don’t see more than one of them - Mira
  • This is not the strange behavior of the beatback, it is the usual behavior of the gita. fetch --prune - it deletes only references to the remote repo and this is logical. If it were not so: That was your "mySuperFeature" branch, and it was on a remote repo. Then admin Vasya decided to clean the repo from the garbage and your branch completely accidentally demolished. You have done fetch --prune and your feature is imperceptibly lost. All in despair. - Duck Learns to Take Cover

1 answer 1

You need to run the git fetch command with the prune flag.

 git fetch --prune 

If there are several remote repositories, you can specify a specific one:

 git fetch origin --prune 

Same:

 git remote prune origin 

This will remove references to remote repository branches that no longer exist.

At the same time, you may still have local branches with which you worked and which previously referred to non-existent branches of the remote repo.

These branches should be removed with pens using:

 git branch -d 
  • one
    You can delete all locked local: git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d . It is not exactly the same, but almost. - Nick Volynkin