git
坑待填
COPY SSHKEY
代码语言:javascript复制ssh-copy-id user@ip
POST-RECEIVE
代码语言:javascript复制#!/bin/bash
WEBDIR=/var/www/html/
git --work-tree=${WEBDIR} clean -fd
git --work-tree=${WEBDIR} checkout -f
代码语言:javascript复制#!/bin/sh
#
# An example hook script for the "post-receive" event.
#
# The "post-receive" script is run after receive-pack has accepted a pack
# and the repository has been updated. It is passed arguments in through
# stdin in the form
# <oldrev> <newrev> <refname>
# For example:
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
#
# see contrib/hooks/ for a sample, or uncomment the next line and
# rename the file to "post-receive".
#. /usr/share/git-core/contrib/hooks/post-receive-email
#git 仓库
while read oldrev newrev ref
do
branch=$(git rev-parse --symbolic --abbrev-ref $ref)
if [ "$branch" = "master" ]
then
git push -f fenke:/mob/fenke.git $branch
else
git push -f fenke_test:/mob/fenke.git $branch
fi
done
# 项目服务器(也搭建一个git仓库)
while read oldrev newrev ref
do
if [[ $ref =~ .*/3.0$ ]];
then
echo "test ref received. Deploying fenke3.0 branch to test server..."
git --work-tree=/var/www/html/test --git-dir=$GIT_DIR checkout -f $ref
else
echo "Ref $ref successfully received. Doing nothing: only the 3.0 branch may be deployed on this server."
fi
done