Files
soul-yongping/从GitHub下载最新.sh
2026-03-07 22:58:43 +08:00

51 lines
1.7 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 从 GitHub fnvtk/Mycontent 的 yongpxu-soul 分支下载最新到「一场soul的创业实验-永平」
# 用法: bash 从GitHub下载最新.sh
set -e
REPO="https://github.com/fnvtk/Mycontent.git"
BRANCH="yongpxu-soul"
YONGPING_ROOT="/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平"
TMP_DIR="/tmp/Mycontent_yongpxu_soul_dl"
echo "===== 1. 查询远程最新 commit ====="
git ls-remote "$REPO" "refs/heads/$BRANCH" 2>/dev/null || { echo "无法连接 GitHub请检查网络或代理"; exit 1; }
echo ""
echo "===== 2. 克隆/更新 $BRANCH 到临时目录 ====="
if [ -d "$TMP_DIR" ]; then
cd "$TMP_DIR"
git fetch origin "$BRANCH" 2>/dev/null || true
git checkout "$BRANCH" 2>/dev/null || true
git pull origin "$BRANCH" 2>/dev/null || true
else
git clone --depth 1 --branch "$BRANCH" "$REPO" "$TMP_DIR"
cd "$TMP_DIR"
fi
echo ""
echo "===== 3. 最近 5 次提交(本次会同步的内容)====="
git log -5 --oneline
echo ""
echo "===== 4. 同步到永平目录(覆盖 soul-admin / soul-api / miniprogram / 开发文档 / scripts 等)====="
# 不删本地独有文件,只覆盖仓库里有的
for dir in soul-admin soul-api miniprogram 开发文档 scripts; do
if [ -d "$TMP_DIR/$dir" ]; then
echo " 同步 $dir ..."
rsync -a --exclude='node_modules' --exclude='.next' --exclude='dist' "$TMP_DIR/$dir/" "$YONGPING_ROOT/$dir/"
fi
done
# 根目录常见文件
for f in content_upload.py 本机运行文档.md; do
if [ -f "$TMP_DIR/$f" ]; then
cp "$TMP_DIR/$f" "$YONGPING_ROOT/$f"
echo " 复制 $f"
fi
done
echo ""
echo "===== 完成 ====="
echo "最新已同步到: $YONGPING_ROOT"
echo "如需查看完整差异,可到 $TMP_DIR 执行 git log"