diff --git a/publish.sh b/publish.sh index 0fb51f6..28f2e2b 100755 --- a/publish.sh +++ b/publish.sh @@ -1,6 +1,6 @@ # 设置目标仓库的 URL 和分支 REPO_URL="https://github.com/LJHG/ljhg.github.io.git" -BRANCH="main" +BRANCH="master" # 使用 master 作为分支名 # 检查并创建 mysite 文件夹 if [ ! -d "./mysite" ]; then @@ -8,8 +8,6 @@ if [ ! -d "./mysite" ]; then cd ./mysite git init git remote add origin $REPO_URL - git fetch origin - git checkout $BRANCH || git checkout -b $BRANCH cd .. fi @@ -20,14 +18,19 @@ if [ $? -ne 0 ]; then exit 1 fi -# 提交并推送更改 +# 进入 mysite 并提交更改 cd ./mysite + +# 切换到 master 分支(如果不存在则创建) +git checkout $BRANCH || git checkout -b $BRANCH + +# 提交并推送更改 git add -A -git commit -m "Update site content from GitBook" -git push origin $BRANCH +git commit -m "Initial commit: Update site content from GitBook" +git push -u origin $BRANCH if [ $? -ne 0 ]; then echo "Error: Failed to push changes to $REPO_URL" exit 1 fi -echo "Site successfully built and pushed to $REPO_URL" +echo "Site successfully built and pushed to $REPO_URL on branch $BRANCH"