Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete branches which are not in the local repository using git

There's a bunch of branches on one of my git repo's that I got when I forked it on GitHub. I don't want my GitHub fork to have these branches.

Is there any way that I can delete all the branches on my GitHub repo that are not in my local repo?

like image 554
xenoterracide Avatar asked Feb 26 '23 10:02

xenoterracide


1 Answers

git push --mirror <origin> will make the refs on the remote match those in the local repository, including deleting branches that you don't have locally.

From git help push:

--mirror
    Instead of naming each ref to push, specifies that all refs under
    refs/ (which includes but is not limited to refs/heads/,
    refs/remotes/, and refs/tags/) be mirrored to the remote
    repository. Newly created local refs will be pushed to the remote
    end, locally updated refs will be force updated on the remote end,
    and deleted refs will be removed from the remote end. This is the
    default if the configuration option remote.<remote>.mirror is set.
like image 128
mkarasek Avatar answered Mar 01 '23 09:03

mkarasek