Skip to content

Instantly share code, notes, and snippets.

@pedro-mass
Last active November 18, 2021 16:30
Show Gist options
  • Save pedro-mass/3f9618d385f51f43b26002e5a42ff086 to your computer and use it in GitHub Desktop.
Save pedro-mass/3f9618d385f51f43b26002e5a42ff086 to your computer and use it in GitHub Desktop.
zsh scripts
# Interactive way to select branch. Lists out the commits to help pick the right branch
gcoo() {
is_in_git_repo || return
git branch -a --color=always | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} -v '/HEAD\s' | sort | fzf --ansi --multi --tac --preview-window right:70% --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES | sed 's/^..//' | cut -d' ' -f1 | sed 's#^remotes/origin/##' | xargs git checkout
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment