diff --git a/.bash_aliases b/.bash_aliases index 0f4b7bb..9633fd1 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -83,6 +83,18 @@ gitf () { gitf w ;; + # Checkout [and create] a git branch (defaults to "master") + "b") + local branch="${2:-master}" + + if git show-ref --verify --quiet refs/heads/"$branch"; then + git checkout $branch + return 0 + fi + + git checkout -b $branch + ;; + # Clear local branches that have no upstream on remote (cleanup) "c") git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D