{"record":{"id":"28fcd1d5c8c7046e","repo":"cli/cli","slug":"could-not-parse-push-revision-v","errorCode":null,"errorMessage":"could not parse push revision: %v","messagePattern":"could not parse push revision: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"git/client.go","lineNumber":586,"sourceCode":"\treturn RemoteTrackingRef{\n\t\tRemote: refNameParts[0],\n\t\tBranch: refNameParts[1],\n\t}, nil\n}\n\n// PushRevision gets the value of the @{push} revision syntax\n// An error here doesn't necessarily mean something is broken, but may mean that the @{push}\n// revision syntax couldn't be resolved, such as in non-centralized workflows with\n// push.default = simple. Downstream consumers should consider how to handle this error.\nfunc (c *Client) PushRevision(ctx context.Context, branch string) (RemoteTrackingRef, error) {\n\trevParseOut, err := c.revParse(ctx, \"--symbolic-full-name\", branch+\"@{push}\")\n\tif err != nil {\n\t\treturn RemoteTrackingRef{}, err\n\t}\n\n\tref, err := ParseRemoteTrackingRef(firstLine(revParseOut))\n\tif err != nil {\n\t\treturn RemoteTrackingRef{}, fmt.Errorf(\"could not parse push revision: %v\", err)\n\t}\n\n\treturn ref, nil\n}\n\nfunc (c *Client) DeleteLocalTag(ctx context.Context, tag string) error {\n\targs := []string{\"tag\", \"-d\", tag}\n\tcmd, err := c.Command(ctx, args...)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = cmd.Output()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/git/client.go#L568-L604","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nref, err := client.PushRevision(ctx, branch)\nif err != nil {\n    return err // hard-fails on branches with no push target\n}\n\n// after\nref, err := client.PushRevision(ctx, branch)\nif err != nil {\n    // @{push} unresolvable (e.g. no upstream yet, triangular workflow); degrade gracefully\n    ref = git.RemoteTrackingRef{}\n}","handlingStrategy":"fallback","validationCode":"hasUpstream, err := client.HasUpstreamBranch(ctx, branch) // or check 'git branch -vv' output\nif err != nil || !hasUpstream {\n    // no @{push} target: skip push-revision-dependent features instead of calling PushRevision\n}","typeGuard":null,"tryCatchPattern":"ref, err := client.PushRevision(ctx, branch)\nif err != nil {\n    // doc comment says this is often benign (no push target); degrade, don't abort\n    ref = git.RemoteTrackingRef{}\n    warn = true\n}","preventionTips":["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"],"tags":["git","push","rev-parse","workflow"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}