Skip to main content

A handy Git shortcut to fetch and prune

Posted in Development and Git

I’m still writing my Git commands long-hand. No aliases. In revisiting an article from last year, it struck me that there’s a built in shortcut to perform a command that I gave as an example:

It bugs me that pruning doesn’t happen with a fetch, like it does in Tower, so aliasing git fetch && git remote prune origin to gf or something like that would be lovely

Well, it turns out there’s a -prune flag for the fetch command in Git! So while aliasing a fetch and a prune to gf would be going too far (for me), git fetch && git remote prune origin can be written as git fetch -prune, and that’s a proper Git command. Even better, the -prune flag can be shortened to -p! So the shortcut is:

git fetch -p

Now I can refresh my view of the remote repo while at the same time getting rid of ‘dead’ branches up on my remote, all less than half the characters!

Accessibility in your inbox

I send an accessibility-centric newsletter on the last day of every month, containing:

  • A roundup of the articles I’ve posted
  • A hot pick from my archives
  • Some interesting posts from around the web

I don’t collect any data on when, where or if people open the emails I send them. Your email will only be used to send you newsletters and will never be passed on. You can unsubscribe at any time.

More posts

Here are a couple more posts for you to enjoy. If that’s not enough, have a look at the full list.

  1. Avatars and alt text

    I really enjoyed Nicolas Steenhout’s recent article on Alt text for avatars or user photos. But there is a context where I would break his rule…

  2. Upgrading from iPhone 13 mini to 16 Pro

    I get a new phone every 3-ish years, give mine to my wife, and now she gives hers to our daughter. I got a 16 Pro this year! Here’s the skinny.