用脚本来提高使用GIT时的工作效率

GIT是一个非常好的版本管理工具。我从接触到Ruby开发后,一直使用GIT。
工作中,常用的几个GIT命令不外乎add、commit、pull、push。命令虽然不长,但每天敲来敲去的,也有些麻烦。为此,我设计了一个脚本,把几个命令写进去,使用的时候,只要按一个键就可以完成操作,自以为方便了很多。
好,现在就来分享一下这个脚本,有不足之处,欢迎高手赐教。


#!/bin/bash

COMMAND=""
while [ "$COMMAND" != "q" ]
do
	echo 
	echo '~~~~~~~~~~~~~~~~~~~~'
	echo "Select a command:"
	echo "s. status"
	echo "a. add -Av"
	echo "c. commit -avm"
	echo "p. push -v"
	echo "u. pull -v"
	echo "v. archive"
	echo "q. exit"
	echo '~~~~~~~~~~~~~~~~~~~~'
	read -r -s -n 1 COMMAND
	echo ''
    if [ "$COMMAND" = "s" ] ; then
		echo ">> git status"
    	git status
    elif [ "$COMMAND" = "a" ] ; then
		echo ">> git add -Av"
    	git add -Av
    elif [ "$COMMAND" = "c" ] ; then
    	echo ">> Please input a message: "
		read MESSAGE
		echo ">> git commit -avm \"$MESSAGE\""
		git commit -avm "$MESSAGE"
    elif [ "$COMMAND" = "p" ] ; then
		echo ">> git push -v"
    	git push -v
    elif [ "$COMMAND" = "u" ] ; then
		echo ">> git pull -v"
    	git pull -v
	elif [ "$COMMAND" = "v" ] ; then
		echo ">> git archive master | bzip2 > source-tree.tar.bz2"
		git archive master | bzip2 > ../source-tree.tar.bz2
	elif [ "$COMMAND" = "q" ] ; then
	    exit 0
	else
		continue
	fi
done



(完)

你可能感兴趣的:(工作,git,脚本,bash,Ruby)