diff --git a/engine.go b/engine.go index 7abe694..9abbf93 100644 --- a/engine.go +++ b/engine.go @@ -594,6 +594,13 @@ func (e *Engine) syncOnce(s *repoState, trigger string) { s.mu.Unlock() e.pushStatus(s) + if ahead > 0 && (cfg.Mode == "push" || cfg.Mode == "both") { + if !e.pushAll(s, cfg, ahead) { + // 推送失败,本轮终止,避免继续拉取加剧分叉 + e.setFail(s, "推送失败,本轮同步已终止(跳过拉取以避免分叉加剧)") + return + } + } if behind > 0 && (cfg.Mode == "pull" || cfg.Mode == "both") { if !e.pullRemote(s, cfg, remote, behind) { return diff --git a/logs/git-auto-sync.log b/logs/git-auto-sync.log index baf5483..d73d4f6 100644 --- a/logs/git-auto-sync.log +++ b/logs/git-auto-sync.log @@ -80,3 +80,10 @@ error: failed to push some refs to 'https://git.shiroko.one/tamakyi/github-auto- [2026-09-08 17:30:43] === 同步完成(本地领先 0,落后 0)=== [2026-09-08 17:31:43] === 开始同步(定时检查,模式 push)=== [2026-09-08 17:31:51] 检测到 4 个未提交改动,执行自动提交 +[2026-09-08 17:31:54] 自动提交完成,将随本轮同步推送 +[2026-09-08 17:31:56] 远程分支 origin/main 不存在(远程仓库可能为空或分支名不一致),将推送本地 12 个提交以建立远程分支 +[2026-09-08 17:31:58] 推送至 origin 失败: error: src refspec main does not match any +error: failed to push some refs to 'https://git.shiroko.one/tamakyi/github-auto-sync-golang' +[2026-09-08 17:31:59] === 同步完成(本地领先 0,落后 0)=== +[2026-09-08 17:32:59] === 开始同步(定时检查,模式 push)=== +[2026-09-08 17:33:07] 检测到 3 个未提交改动,执行自动提交 diff --git a/stats/git-auto-sync.csv b/stats/git-auto-sync.csv index c4f048a..2c8f0a6 100644 --- a/stats/git-auto-sync.csv +++ b/stats/git-auto-sync.csv @@ -10,3 +10,4 @@ timestamp,action,result,commits 2026-09-08 17:27:05,push,failed,9 2026-09-08 17:28:21,push,failed,10 2026-09-08 17:30:42,push,failed,11 +2026-09-08 17:31:58,push,failed,12