git automatic submission script

Over and over again every time linux have knocked these duplicate code, I think it can be optimized, to be a key script, reduce duplication of effort.

#!/bin/bash
git status
 
read -r -p "whether to continue to submit? [Y / n]" input
 
case $input in
    [yY][eE][sS]|[yY])
        echo "continue to submit"
        git add -A
        git commit -m $1
        git push origin $2
                    exit 1
        ;;

    [Nn] [Oo]. [Nn])
        echo "interrupt submit"
        exit 1
            ;;

    *)
    echo "input errors, please re-enter"
    ;;
esac
        

When the actual operation of the command line, type: ./ gitcommit.sh commitMesage branchName on it

Circulation submit scripts

#!/bin/bash
git status
 
while true;
do
    read -r -p "whether to continue to submit? [Y / n]" input
 
    case $input in
        [yY][eE][sS]|[yY])
            echo "continue to submit"
            git add -A
            git commit -m $1
            git push origin $2
                        exit 1
            ;;
 
        [Nn] [Oo]. [Nn])
            echo "interrupt submit"
            exit 1
                   ;;
 
        *)
        echo "input errors, please re-enter"
        ;;
    esac
done

Operating with a single submission as

Sometimes, we submit code with local development svn, submitted to the code repository, and then pushed to the target server code repository

 

#!/bin/bash
code path cd
svn up
version=`svnversion |sed 's/^.*://' |sed 's/[A-Z]*$//'`
#version=`svn info|grep "Last Changed Rev"`
branch = Warehouse Address

git status
 
read -r -p "whether to continue to submit? [Y / n]" input
 
case $input in
    [yY][eE][sS]|[yY])
        echo "continue to submit"
        git add .
        git commit -m $version
        git push $branch master
        ;;
 
    [Nn] [Oo]. [Nn])
        echo "interrupt submit"
        exit 1
               ;;
 
    *)
    echo "input error"
    exit 1
    ;;
esac

When executed directly ./gitbash.sh just fine, because I submit the information with the address of the warehouse is to write directly dead

 

Guess you like

Origin www.cnblogs.com/reasonzzy/p/11653895.html