Linux 下git 相关操作的脚本

2017-07-08  本文已影响6人  zeekling

本人经常使用git 版本控制工具,在使用过程中写了一个脚本:

#!/usr/bin/env bash
# 本脚本用于提交所有代码到远程仓库的脚本,简化操作
# 脚本使用:./mygit 分支名称 提交的信息
# author: zeekling

BRANCH=master
if ! test -z $1;then
    BRANCH=$1
fi
# 修复以前提示信息不能传入空格的bug 
shift 1
if test -z $*;then
    git add -A
    git commit &&
        git pull origin ${BRANCH} && git push origin ${BRANCH}
    exit 0
else
    git add -A
    git commit -m "$*" &&
        git pull origin ${BRANCH} && git push origin ${BRANCH}
    exit 0
fi

我将其命名为mygit.sh,赋予其权限(非root用户要加sudo)

sudo chmod +x mygit.sh

将其拷贝到/usr/tools/下面
最后执行语句

sudo ln -s /usr/tools/mygit.sh /usr/bin/mygit

然后输入

whereis mygit

得到如下结果

mygit: /usr/bin/mygit

使用时,语句

mygit branch 提交时的备注
上一篇下一篇

猜你喜欢

热点阅读