Skip to content

Force pushing on a spec task branch doesn't work. It fail...#1786

Merged
lukemarsden merged 3 commits intomainfrom
feature/001289-force-pushing-on-a-spec
Mar 2, 2026
Merged

Force pushing on a spec task branch doesn't work. It fail...#1786
lukemarsden merged 3 commits intomainfrom
feature/001289-force-pushing-on-a-spec

Conversation

@lukemarsden
Copy link
Collaborator

Helix: Force pushing on a spec task branch doesn't work. It fails with the following error in the Helix API server, but agents should be able to force push on their branches, I think.

uhoh force push failed with api-1 | 2026-02-17T07:33:45Z ERR pkg/services/git_repository_service_push.go:98 > [GitPush] FAILED to push to external repository error="PushOu
tOfDate Error: exit status 1 - To https://github.com/helixml/helix\n ! [rejected] feature/001036-we-badly-need-to -> feature/001036-w
e-badly-need-to (non-fast-forward)\nerror: failed to push some refs to 'https://github.com/helixml/helix'\nhint: Updates were rejected because a
pushed branch tip is behind its remote\nhint: counterpart. If you want to integrate the remote changes, use 'git pull'\nhint: before pushing ag
ain.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n - To https://github.com/helixml/helix\n ! [rejected]
feature/001036-we-badly-need-to -> feature/001036-we-badly-need-to (non-fast-forward)\nerror: failed to push some refs to 'https://github.com
/helixml/helix'\nhint: Updates were rejected because a pushed branch tip is behind its remote\nhint: counterpart. If you want to integrate the r
emote changes, use 'git pull'\nhint: before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n: To htt
ps://github.com/helixml/helix\n ! [rejected] feature/001036-we-badly-need-to -> feature/001036-we-badly-need-to (non-fast-forward)\ne
rror: failed to push some refs to 'https://github.com/helixml/helix'\nhint: Updates were rejected because a pushed branch tip is behind its remo
te\nhint: counterpart. If you want to integrate the remote changes, use 'git pull'\nhint: before pushing again.\nhint: See the 'Note about fast-
forwards' in 'git push --help' for details.\n\n" auth_type=basic:x-access-token branch=feature/001036-we-badly-need-to external_url=https://gith
ub.com/helixml/helix push_duration=299.292469 repo_id=prj_01kg02vqqyg178c1n2ydscn5fb-helix-4 total_elapsed=312.103003
api-1 | 2026-02-17T07:33:45Z ERR pkg/services/git_http_server.go:610 > Failed to push branch to upstream - rolling back error="failed to push t
o external repository: PushOutOfDate Error: exit status 1 - To https://github.com/helixml/helix\n ! [rejected] feature/001036-we-badl
y-need-to -> feature/001036-we-badly-need-to (non-fast-forward)\nerror: failed to push some refs to 'https://github.com/helixml/helix'\nhint: Up
dates were rejected because a pushed branch tip is behind its remote\nhint: counterpart. If you want to integrate the remote changes, use 'git p
ull'\nhint: before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details.\n - To https://github.com/helixml/
helix\n ! [rejected] feature/001036-we-badly-need-to -> feature/001036-we-badly-need-to (non-fast-forward)\nerror: failed to push som
e refs to 'https://github.com/helixml/helix'\nhint: Updates were rejected because a pushed branch tip is behind its remote\nhint: counterpart. I
f you want to integrate the remote changes, use 'git pull'\nhint: before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push -
-help' for details.\n: To https://github.com/helixml/helix\n ! [rejected] feature/001036-we-badly-need-to -> feature/001036-we-badly-
need-to (non-fast-forward)\nerror: failed to push some refs to 'https://github.com/helixml/helix'\nhint: Updates were rejected because a pushed
branch tip is behind its remote\nhint: counterpart. If you want to integrate the remote changes, use 'git pull'\nhint: before pushing again.\nhi
nt: See the 'Note about fast-forwards' in 'git push --help' for details.\n\n" branch=feature/001036-we-badly-need-to repo_id=prj_01kg02vqqyg178c
1n2ydscn5fb-helix-4

When an agent force-pushes to their feature branch (e.g., after rebasing),
detect this by checking if the old commit is an ancestor of the new commit.
If not (force push), propagate the force flag to PushBranchToRemote so the
upstream push uses --force.

Changes:
- detectChangedBranches now returns map[string]bool (branch -> isForce)
- Added repoPath parameter for running git merge-base --is-ancestor
- Log force push detection with old/new commit hashes
- Pass isForce flag to PushBranchToRemote call

This allows agents to recover from stuck states by force-pushing after
rebasing onto the latest base branch.

Spec-Ref: helix-specs@497a41c80:001289_force-pushing-on-a-spec
Reuse pattern from existing codebase - adds IsAncestor() to gitea_git_helpers.go
and uses it in detectChangedBranches instead of inline git command.

Spec-Ref: helix-specs@d70fa2e18:001289_force-pushing-on-a-spec
@lukemarsden lukemarsden merged commit 789a04e into main Mar 2, 2026
1 of 3 checks passed
@lukemarsden lukemarsden deleted the feature/001289-force-pushing-on-a-spec branch March 2, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant