Last active
August 22, 2024 21:12
-
-
Save AliciaMoses/39293e2e9e9eeafab4e27cb0821cec60 to your computer and use it in GitHub Desktop.
fzf + `git checkout`
This file contains 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
function gxo() { | |
local branches branch | |
branches=$(git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)') || return | |
# Add a separator and then list all branches | |
branches="$branches"$'\n'"$(git branch --all | grep -v '\->' | sed 's/^[* ]*//')" || return | |
# Use fzf to select a branch + added useless but cool looking graph | |
branch=$(echo "$branches" | fzf --height 40% --border --preview 'git log --oneline --graph --decorate --color=always {}') || return | |
git checkout $(echo "$branch" | sed 's#^remotes/[^/]*/##') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment