赞
踩
对于个人的小项目来说,使用github来push的时候无非只是用几个命令,而每次都要输又比较麻烦,于是写了这个小脚本供大家使用。
该脚本使用了下面几个命令:
git add . #添加目录下所有文件到git
git commit -m "xxx" #上传,并且commit message为引号中内容(可自定)
git push origin master #合并branch到master
#!/bin/sh
if [ $# == 1 ]; #判断参数个数
then #若参数正确执行代码
git add .
message=$1
git commit -m "${message}"
git push origin master
else #参数错误则输出Usage
echo '[usage]'
echo 'gitPush [COMMIT MESSAGE]'
fi
【针对现有repo】
将脚本copy到/usr/local/bin/gitPush.sh, 然后重启一下shell,运行gitPush.sh 'abc def'
那么该目录下的所有文件将被上传,并且本次commit message为 “abc def”
【针对新建项目】
先在GitHub新建一个repo,然后在电脑中找一个位置使用git clone +[你的项目地址]
来拷贝下来,然后再使用上面的方法上传即可。
脚本也可以直接到我的GitHub repo下载:GitHub | MyConsoleTools
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。