Talespin_Kit
Talespin_Kit

Reputation: 21897

How can I delete a remote branch in a local Git repository?

All the remote branches are visible as remotes in my local Git repository after a Git fetch.

How can I selectively remove the remote branches in my local repository (not in the remote repository)?

Upvotes: 53

Views: 16714

Answers (2)

Ilya Ivanov
Ilya Ivanov

Reputation: 2499

Use:

git branch -r -d remote/branch

You also need to reconfigure fetch to avoid fetching this branch again later.

Upvotes: 64

Thomas Levesque
Thomas Levesque

Reputation: 292625

I had a slightly different but similar issue, but the solution might be useful to others who stumble on this question...

I noticed that my local repository still had remote branches that no longer existed on the remote, so I wanted to remove them. The solution is simply to fetch with the --prune (or -p) option:

git fetch --prune

Upvotes: 84

Related Questions