4 ms·
I've shared it before but my tool for switching git branches based on time (it's called flog because I always read reflog as re-flog not ref-log) flog () {
by 1-more 3y ago
I've shared it before but my tool for switching git branches based on time (it's called flog because I always read reflog as re-flog not ref-log)
flog () {
branch="$(
git branch --sort=-committerdate --format="%(committerdate:relative)%09%(refname:short)%09%(subject)" \
| column -ts $'\t' \
| fzf \
| sed 's/.*ago \+\([^ ]*\) .*/\1/'
)"
git co $branch || (
echo -n "git co $branch" | pbcopy
)
}
I have a much longer one for switching between PRs requesting my review and previewing them while I do it.
edit: funny story, I went to add 4 spaces to the start of each line and it turns out I did the same thing last time and my autocomplete got it for me
which flog | sed 's/^/ /' | pbcopy
- nicbarth 3y agoCool idea! I actually do something similar albeit without sorting. The idea is if you check out a remote branch it'll track it. gbb() { eval $(echo git checkout "$(git branch --all \ | fzf --height 10 \ | tr -d '[:space:]' \ | tr -d '*' \ | sed 's/remotes\//\-\-track /g')") }