本人經常使用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 提交時的備注