Git: Get local branches with no remote

If you often jump between branches and sometimes lose track of which you have and haven’t pushed to the remote yet, it might be handy to get all local branches with no remote:

git branch --format "%(refname:short) %(upstream)" | awk '{if (!$2) print $1;}'

To sort the whole shebang recently modified branches first, you can add --sort=-committerdate

git branch --format "%(refname:short) %(upstream)" --sort=-committerdate | awk '{if (!$2) print $1;}'

If you use this often, adding an alias might be handy:

alias git-recent-local="git branch --format '%(refname:short) %(upstream)' --sort=-committerdate | awk '{if (!\$2) print \$1;}'"