raacer
raacer

Reputation: 5481

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.

Upvotes: 4

Views: 530

Answers (1)

raacer
raacer

Reputation: 5481

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

Upvotes: 2

Related Questions