Created
May 24, 2019 13:22
-
-
Save wojas/14bd28db35ec87b6e031a5f48ad48f9a to your computer and use it in GitHub Desktop.
Script to visually select a recent git branch to switch to
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to visually select a recent git branch to switch to | |
# Requires https://github.com/junegunn/fzf (brew install fzf) | |
branches () { | |
git for-each-ref --sort=-committerdate refs/heads/ | sed 's|.*refs/heads/||' | head -30 | |
} | |
branch=$(branches | fzf --no-sort --layout=reverse) | |
set -ex | |
git checkout "$branch" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment