Prune local tracking of stale remote branches

If you suffer from OCD like myself, you’ll likely be just as annoyed by the output of 

git branch -a
which (in a well-used local repo) after a while will show a long list of remote branches (origin/blah) the vast majority of which no longer exist.
The solution to the annoyance (which makes it difficult to locate an actually useful remote branch in the middle of the clutter) is to run:
git remote prune origin
[Note – this does NOT touch `origin`, but only acts locally on your .git/remotes directory]
For more context, see this thread.
On the same note, please remember that
git push origin :stale_branch
is a thoughtful command to run regularly on your no-longer-used tracking remote branches, as a courtesy to your OCD-suffering colleagues 🙂
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s