From d3772eb469e665d376d2c7b67ff42c36fa2b3b0a Mon Sep 17 00:00:00 2001 From: vanpipy Date: Wed, 18 Nov 2020 22:50:13 +0800 Subject: [PATCH] feat(feature): checkout from start point if exists --- bin/git-feature | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/bin/git-feature b/bin/git-feature index 8712008..3a5e0ce 100755 --- a/bin/git-feature +++ b/bin/git-feature @@ -32,6 +32,10 @@ do --squash ) merge_mode="--squash" ;; + --from ) + start_point=$2 + shift + ;; * ) argv+=($1) ;; @@ -55,10 +59,24 @@ else else branch="$branch_prefix"/"${argv[0]}" fi - if [[ -n $remote ]] + + if [[ -n $remote ]] && [[ -z $start_point ]] then git create-branch -r $remote $branch - else + fi + + if [[ -z $remote ]] && [[ -z $start_point ]] + then git create-branch $branch fi + + if [[ -n $remote ]] && [[ -n $start_point ]] + then + git create-branch -r $remote --from $start_point $branch + fi + + if [[ -z $remote ]] && [[ -n $start_point ]] + then + git create-branch --from $start_point $branch + fi fi