Monthly Archives: June 2016

Handy git commands

If like me, you occasionally use Sourcetree or similar Git GUI to quickly change branch, after a while you may find yourself with 200 branches in the left side, making this task a lot harder (and making you wonder why you’re not just using the command line!).

A quick remedy to this is to run:

git branch -d $(git branch --merged)

This rids you of any branches that have been merged, leaving you with a nice clean branch list.

If you then find yourself with a large pile of branches you never pushed to remote and merged (and indeed never will), you could then run:

git remote prune origin

This will remove any branches that are only on your local. Make sure you push whatever branches you’re working on first though!

Enjoy!