logo

Git Repo 的创建


本文用来记录一个用来创建 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

欢迎转载,转载请保留:
转自Elta 的博客:https://elta.github.io//2017/04/24/gitrepo.html

扫描或长按二维码进行打赏:
WechatPayInPost




分类:  linux ,
标签:  git , autoscript ,
上篇: 记录一次 QEMU 网卡的调试 下篇: 著名的 Linux 系统构建工具