Created
February 7, 2019 06:52
-
-
Save onigra/3da6966bfda8b7d6a6614b159abd1a1b to your computer and use it in GitHub Desktop.
remote branch 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 gcp() { | |
local res | |
local branch=$(git branch -a | peco | tr -d ' ') | |
if [ -n "$branch" ]; then | |
if [[ "$branch" =~ "remotes/" ]]; then | |
local b=$(echo $branch | cut -d '/' -f 3-) | |
res="git checkout -b ${b} ${branch}" | |
else | |
res="git checkout ${branch}" | |
fi | |
fi | |
_cool-peco-on-complete "$res" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment