gitサボりの提出方法

6372 ワード

私はこれまで怠け者だった.
gitを使って提出するときは、命令をたくさん叩くので、煩雑です.まず、エイリアス短縮入力の命令を定義できます.
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.df diff
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.mg merge

btw、これでまだ問題が解決していませんね.やはりうるさいですね.shスクリプトを書いて、自動的に提出できるかどうか試してみましょう.考えがあれば彼になり、次のシナリオがありました.
#!/bin/sh
#    
#       
G_GIT_BRANCH="your_branch"
G_GIT_MASTER_BRANCH="master"
G_GIT_PATH=$(pwd)
echo  "\033[32m   :$G_GIT_PATH  \033[0m"
echo  "\033[32m   :$G_GIT_BRANCH  \033[0m"

cd $G_GIT_PATH

function checkGitStatus
{
    STR1="nothing to commit, working tree clean"
    STR2="no changes added to commit"
    STR3="Changes not staged for commit"
    STR4="Changes to be committed"
    STR5="both modified: "
    STR6="Untracked files:"
    OUTTYPE=-1
    out=$(git status)
    result=$(echo $out | grep "$STR5")
    if [[ "$result" != "" ]];then
        OUTTYPE=5
    fi
    if [ "$OUTTYPE" == "-1" ];then
        result=$(echo $out | grep "$STR1")
        if [[ "$result" != "" ]];then
            OUTTYPE=1
        fi
    fi
    if [ "$OUTTYPE" == "-1" ];then
        result=$(echo $out | grep "$STR6")
        if [[ "$result" != "" ]];then
            OUTTYPE=6
        fi
    fi
    if [ "$OUTTYPE" == "-1" ];then
        result=$(echo $out | grep "$STR2")
        if [[ "$result" != "" ]];then
            OUTTYPE=2
        fi
    fi
    if [ "$OUTTYPE" == "-1" ];then
        result=$(echo $out | grep "$STR3")
        if [[ "$result" != "" ]];then
            OUTTYPE=3
        fi
    fi
    if [ "$OUTTYPE" == "-1" ];then
        result=$(echo $out | grep "$STR4")
        if [[ "$result" != "" ]];then
            OUTTYPE=4
        fi
    fi
    if [ "$OUTTYPE" == "-1" ];then
        result=$(echo $out | grep "$STR5")
        if [[ "$result" != "" ]];then
            OUTTYPE=5
        fi
    fi
    if [ "$OUTTYPE" == "1" ];then
        git status
        echo "          ."
        echo "     1:Pull master 2:  "
        read choose
        if [ $choose = "1" ];then
            echo "  :git checkout $G_GIT_MASTER_BRANCH"
            ret=$(git checkout $G_GIT_MASTER_BRANCH )
            #            ??
            echo "  :git pull origin $G_GIT_MASTER_BRANCH"
            git pull origin $G_GIT_MASTER_BRANCH
            echo "  :git checkout $G_GIT_BRANCH"
            git checkout $G_GIT_BRANCH
            echo "     1:Merge    2:  "
            read choose
            if [ $choose = "1" ];then
                echo "  :git merge $G_GIT_MASTER_BRANCH"
                ret=$(git merge $G_GIT_MASTER_BRANCH)
                #TODO:       
                kstr="conflicts" #  
                result=$(echo $ret | grep "$kstr")
                if [[ "$result" != "" ]];then
                    echo "    "
                    exit 2
                fi
                echo "     1:        2:  "
                read choose
                if [ $choose = "1" ];then
                    echo "  :git push origin $G_GIT_BRANCH"
                    git push origin $G_GIT_BRANCH
                    echo "  ,    "
                    exit 2  
                else
                    echo "    "
                    exit 2  
                fi
            else
                echo "    "
                exit 2  
            fi
        else
            echo "    ,    "
            exit 2  
        fi
    elif [ "$OUTTYPE" = "2" ]||[ "$OUTTYPE" = "6" ];then #
        git status
        echo "     "
        echo "     1:  'git add -A' 2:      "
        read choose
        if [ $choose = "1" ];then
           git add -A
        elif [ $choose = "2" ];then
            echo "    ,    "
            exit 2  
        else
            echo "    ,    "
            exit 2  
        fi
    elif [ "$OUTTYPE" = "3" ];then
        git status
        echo "     "
        echo "     1:  'git add -A' 2:      "
        read choose
        if [ $choose = "1" ];then
           git add -A
        elif [ $choose = "2" ];then
            echo "    ,    "
            exit 2  
        else
            echo "    ,    "
            exit 2  
        fi
    elif [ "$OUTTYPE" = "4" ];then
        echo "     "
        echo "     1:  'git commit -m   ' 2:  "
        read choose
        if [ $choose = "1" ];then
            echo "\033[31m       :          \033[0m"
            echo "\033[32m:feat(   feature)     \033[0m"
            echo "\033[32m:fix(  bug)           \033[0m"
            echo "\033[32m:docs(  documentation) \033[0m"
            echo "\033[32m:style(  )            \033[0m"
            echo "\033[32m:refactor(  )         \033[0m"
            echo "\033[32m:test(    )       \033[0m"
            echo "\033[32m:chore(            ) \033[0m"
            read commitType
            echo "    commit  "
            read commitStr
            git commit -m " $commitType commit:$commitStr"
            echo "   commit"

        elif [ $choose = "2" ];then
            echo "    ,    "
            exit 2  
        else
            echo "    ,    "
            exit 2  
        fi
    elif [ "$OUTTYPE" = "5" ];then
        echo "    !!!"
        exit 2  
    fi
}

while true;
do
    checkGitStatus
done


スクリプトにautogit.shと名前を付け、gitディレクトリに配置します.ignoreファイルでは、このファイルを無視します.そして使えます!
カタログでsh autogit.shを直接叩いて、それから1を叩いて、車に戻ります.
毎回アカウントパスワードの入力が要求される場合は、長期保存を設定できます.
git config --global credential.helper store