Created
June 3, 2025 16:39
-
-
Save selfish/9484c19cb85f18604bc91ea5846646d9 to your computer and use it in GitHub Desktop.
Fuzzy Checkout from Recent Branches in Git
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
| ccr() { | |
| local limit branch | |
| # shellcheck disable=SC2031 | |
| limit="${1:-15}" | |
| branch="$(git reflog | awk '/checkout:/ {print $NF}' | awk '!seen[$0]++' | head -n "${limit}" | fzf --prompt "Select a recent branch: ")" | |
| [ -n "${branch}" ] && git switch "${branch}" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment