1

I have a git repo where I pushed my latest changes to a remote. In the last days I deleted several branches locally but couldn't remove them on the remote, since I didn't have any connection to the git server.

Is there a way to delete the remote branches, which don't exist anymore on my local repo? We talk about 200 branches, so a manual approach is not desired.

I found several answers to delete a local branch, that does not exist on the remote anymore via git fetch --prune, in my case I am looking for the other way around.

Any help is highly appreciated

Daniel Stephens
  • 1,649
  • 6
  • 23
  • 59
  • 1
    Does this answer your question? [How do I delete a Git branch locally and remotely?](https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely) – phd Mar 22 '20 at 09:44
  • https://stackoverflow.com/search?q=%5Bgit%5D+prune+remote+branches+ – phd Mar 22 '20 at 09:44
  • 1
    https://stackoverflow.com/a/13437928/7976758: [`git push --prune origin`](https://git-scm.com/docs/git-push#Documentation/git-push.txt---prune) – phd Mar 22 '20 at 09:44
  • 1
    Upvote the linked answer, that would be enough. – phd Mar 22 '20 at 18:01
  • @phd but it doesn't answer my question. I was looking for the --prune option – Daniel Stephens Mar 22 '20 at 22:57
  • 1
    [This one](https://stackoverflow.com/a/13437928/7976758) starts with it. – phd Mar 23 '20 at 07:58

1 Answers1

1

If you want to remove multiple branches one single command you can try this,

git push origin --delete <branch1> <branch2> <branch3>

If you want the list of the remote branch you can try this command first. Then just copy-paste the list into the above command.

git branch -r
Anurodh Singh
  • 758
  • 4
  • 9