Skip to content

Instantly share code, notes, and snippets.

@fkei
Created February 4, 2014 02:40

Revisions

  1. fkei created this gist Feb 4, 2014.
    71 changes: 71 additions & 0 deletions git-feature-start
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    #!/bin/bash
    #
    # git-feature-start - Git リポジトリディレクトリで、指定したブランチ名でブランチを作成し、合わせてリモートブランチも作成するコマンド
    #

    pushd `dirname $0` >/dev/null 2>&1
    [ $? -eq 1 ] && exit 1
    __script_dir=`pwd`
    popd >/dev/null 2>&1
    __base_dir=`dirname ${__script_dir}`
    __dir=`pwd`

    echo "=========="
    echo " ____ _ _ _____ _ "
    echo " / ___(_) |_ | ___|__ __ _| |_ _ _ _ __ ___ "
    echo "| | _| | __| | |_ / _ \/ _\` | __| | | | '__/ _ \ "
    echo "| |_| | | |_ | _| __/ (_| | |_| |_| | | | __/ "
    echo " \____|_|\__| |_| \___|\__,_|\__|\__,_|_| \___| "

    echo ""
    echo ">> Start!! Directory: $__dir"

    if [ ! -d ".git" ]; then
    echo "[ERROR] Not a Git repository."
    exit 1
    fi


    echo -n ">> Branch Name: "
    read name
    echo ""


    # init

    echo ">> State of the branch"
    git branch -a
    echo ""


    echo ">> git checkout develop"
    git checkout develop
    echo ""

    echo ">> git pull --all"
    git pull --all
    echo ""

    echo -n ">> Do you want to run? [y|n]"
    read run
    echo ""

    if [ "x$run" != "xy" ]; then
    echo "Treatment interruption"
    exit 1
    fi

    echo "git branch $name"
    git branch $name
    echo ""

    echo "git checkout $name"
    git checkout $name
    echo ""

    echo ">> push remote ripository"
    echo "git push origin $name"
    git push origin $name

    echo ""
    echo "Finish!!!!!!!!!!"