本文用来记录一个用来创建 Git Repo 的脚本。
脚本内容如下:
#! /bin/bash
function out
{
echo $1
}
function errorout
{
echo $1 > /dev/stderr
}
filename=""
if [ $# == 0 ]; then
errout "Usage:"
errout "$0 proj-name"
exit 1
fi
filename = $1
B_PWD=$(pwd)
out "Checking project's name"
if [ -d $filename ]; then
errout "Project already existted!"
exit 1
fi
out "Init project"
git init --bare $filename
out "Update project option"
pushd #filename
cd hooks/
cp post-update.sample post-update
popd
echo "All operations done."
还有一个自动提交脚本,用来提交所有新增文件和改动,脚本内容如下:
REPO_PATH=yourrepopath
DATE=$(date +"%y-%m-%d %H:%M:%S")
pushd ${REPO_PATH}
if [ $(git status -s | wc -l) == 0 ]; then
echo "Nothing update"
else
git st -s | awk {'print $2'} | xargs git add
CMT_MSG=$(git st)
git commit -a -m "${DATE} ${CMT_MSG}"
fi
popd