Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove all remote git branches

I want to remove locally all branches that I can see with git branch -r. I've already removed all files from .git/refs/remote/*/ and appropriate records from .git/info/refs, but they are still there.

like image 957
raacer Avatar asked Oct 24 '25 04:10

raacer


1 Answers

This command did the job:

git branch -r | xargs git branch -r -D

From the manual:

Use -r together with -d to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist in the remote repository or if git fetch was configured not to fetch them again. See also the prune subcommand of git-remote(1) for a way to clean up all obsolete remote-tracking branches.

Thanks to @MrTux

like image 129
raacer Avatar answered Oct 26 '25 19:10

raacer