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

51 lines
1.6 KiB
Bash
Executable File
Raw 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 的 devlop 分支下载最新到「一场soul的创业实验-永平」
# 用法: bash 从GitHub下载最新_devlop.sh
set -e
REPO="https://github.com/fnvtk/Mycontent.git"
BRANCH="devlop"
YONGPING_ROOT="/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平"
TMP_DIR="/tmp/Mycontent_devlop_dl"
echo "===== 1. 查询远程最新 commit ($BRANCH) ====="
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 "最新一条提交时间:"
git log -1 --format="%ci %s"
echo ""
echo "===== 4. 同步到永平目录 ====="
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 "devlop 分支最新已同步到: $YONGPING_ROOT"