Files
users/scripts/push-to-github.sh

46 lines
1.3 KiB
Bash
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 v0/fnvtk-5efaab9c以本地为主
# Token 从卡若AI/金盾/账号密码与资料管理 读取
# 在终端执行: bash scripts/push-to-github.sh
set -e
cd "$(dirname "$0")/.."
# 从卡若AI 账号与API索引 提取 GitHub Token
TOKEN_FILE="$HOME/Documents/个人/卡若AI/01_卡资/_团队成员/金盾/账号密码与资料管理/账号与API索引.md"
if [ -f "$TOKEN_FILE" ]; then
GITHUB_TOKEN=$(grep "Token.*ghp_" "$TOKEN_FILE" | sed -E "s/.*\`([^\`]+)\`.*/\1/")
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "未找到 GitHub Token使用 origin 推送(需已配置凭据)"
PUSH_URL="origin"
else
PUSH_URL="https://${GITHUB_TOKEN}@github.com/fnvtk/users.git"
echo "已从卡若AI 读取 Token"
fi
echo "=== 1. 当前状态 ==="
git status
echo ""
echo "=== 2. 添加所有更改 ==="
git add -A
git status
echo ""
echo "=== 3. 提交 ==="
if git diff --cached --quiet; then
echo "没有需要提交的更改"
else
git commit -m "chore: 以本地为准,强制同步全部内容"
echo "提交完成"
fi
echo ""
echo "=== 4. 强制推送到 v0/fnvtk-5efaab9c ==="
git push --force "$PUSH_URL" main:v0/fnvtk-5efaab9c
echo ""
echo "=== 完成 ==="
echo "请检查: https://github.com/fnvtk/users/tree/v0/fnvtk-5efaab9c"