LAMP环境下的版本控制实践
一 核心原则与范围
二 代码版本控制与部署
三 数据库版本控制
四 服务器侧Git部署方案
#!/usr/bin/env bash
TARGET="/var/www/html"
GIT_DIR="/home/git/project.git"
BRANCH="master"
while read oldrev newrev ref
do
if [[ "$ref" = "refs/heads/$BRANCH" ]]; then
echo "Deploying $BRANCH branch to $TARGET..."
git --work-tree="$TARGET" --git-dir="$GIT_DIR" checkout -f "$BRANCH"
# 可选:重启服务或清缓存
# sudo systemctl reload apache2
fi
done
五 团队协作与持续交付