cli/cli · warning
could not parse push revision: %v
Error message
could not parse push revision: %v
What it means
Client.PushRevision runs 'git rev-parse --symbolic-full-name <branch>@{push}' and parses the first line with ParseRemoteTrackingRef. This wrapper error fires when that parse fails. As the doc comment warns, failure does not necessarily mean breakage: @{push} may simply be unresolvable, e.g. in non-centralized workflows with push.default=simple where no push target exists.
Source
Thrown at git/client.go:586
return RemoteTrackingRef{
Remote: refNameParts[0],
Branch: refNameParts[1],
}, nil
}
// PushRevision gets the value of the @{push} revision syntax
// An error here doesn't necessarily mean something is broken, but may mean that the @{push}
// revision syntax couldn't be resolved, such as in non-centralized workflows with
// push.default = simple. Downstream consumers should consider how to handle this error.
func (c *Client) PushRevision(ctx context.Context, branch string) (RemoteTrackingRef, error) {
revParseOut, err := c.revParse(ctx, "--symbolic-full-name", branch+"@{push}")
if err != nil {
return RemoteTrackingRef{}, err
}
ref, err := ParseRemoteTrackingRef(firstLine(revParseOut))
if err != nil {
return RemoteTrackingRef{}, fmt.Errorf("could not parse push revision: %v", err)
}
return ref, nil
}
func (c *Client) DeleteLocalTag(ctx context.Context, tag string) error {
args := []string{"tag", "-d", tag}
cmd, err := c.Command(ctx, args...)
if err != nil {
return err
}
_, err = cmd.Output()
if err != nil {
return err
}
return nil
}
View on GitHub (pinned to 0eeec0b92e)
Solutions
- Check 'git rev-parse --symbolic-full-name <branch>@{push}' yourself; if git errors, set an upstream: 'git push -u origin <branch>'
- If the workflow is triangular (pull from upstream, push to fork), accept the error as expected and skip push-target-dependent features
- Inspect the raw rev-parse output for a non-refs/remotes value if git succeeds but parsing fails
- In Go, treat this error as a soft 'no push revision' condition rather than a hard failure (per the function's own doc comment)
Example fix
// before
ref, err := client.PushRevision(ctx, branch)
if err != nil {
return err // hard-fails on branches with no push target
}
// after
ref, err := client.PushRevision(ctx, branch)
if err != nil {
// @{push} unresolvable (e.g. no upstream yet, triangular workflow); degrade gracefully
ref = git.RemoteTrackingRef{}
} Defensive patterns
Strategy: fallback
Validate before calling
hasUpstream, err := client.HasUpstreamBranch(ctx, branch) // or check 'git branch -vv' output
if err != nil || !hasUpstream {
// no @{push} target: skip push-revision-dependent features instead of calling PushRevision
} Try / catch
ref, err := client.PushRevision(ctx, branch)
if err != nil {
// doc comment says this is often benign (no push target); degrade, don't abort
ref = git.RemoteTrackingRef{}
warn = true
} Prevention
- Push new branches with -u before features that need @{push}
- Treat PushRevision errors as 'no push revision' soft states per the function's own documentation
- In triangular workflows, disable push-target features rather than erroring
When it happens
Trigger: Calling PushRevision for a branch with no upstream/remote-tracking branch configured, in a freshly created repo with no remote, a branch never pushed, triangular workflows where push.default=simple defines no @{push}, or when rev-parse succeeds but prints a non-ref string.
Common situations: New local branch not yet pushed; 'origin' remote removed but refs stale; detached HEAD; tools that assume every branch has a push target in fork-based (triangular) workflows.
Related errors
- unknown push.default value: %s
- couldn't get hosts configuration
- ErrLocked
- no git remotes found
- must be run from inside a git repository
AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15).
Data as JSON: /api/errors/28fcd1d5c8c7046e.
Report an issue: GitHub.