修复本地Git仓库为最新时,脚本无法继续的问题。

This commit is contained in:
2026-01-21 16:34:32 +08:00
parent b0ea1753be
commit 0c6e718175

View File

@@ -7,10 +7,10 @@ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
exit 1
fi
# 重置本地修改、切main分支拉最新代码
# 重置本地修改、切main分支拉最新代码(过滤正常提示,仅保留错误输出)
git restore .
git checkout main || { echo "切换main分支失败终止执行"; exit 1; }
git pull origin main --rebase || { echo "拉取main分支最新代码失败终止执行"; exit 1; }
git checkout main 2>&1 | grep -v "Already on '\|Your branch is up to date'" || { echo "切换main分支失败终止执行"; exit 1; }
git pull origin main --rebase 2>&1 | grep -v "Already up to date\|From\|-> FETCH_HEAD" || { echo "拉取main分支最新代码失败终止执行"; exit 1; }
# 优先取HEAD关联tag无则取仓库最近tag
get_latest_tag() {