Skip to content

gh pr view and gh pr status still not detecting ongoing PR branch #7590

Closed as duplicate

Agent suggestions

Public preview

Description

@maxandersen

continuation of #888

still not seeing PRs despite the branch is right.

 4   │ Current branch
   5   │   There is no pull request associated with [codestartmain]
   6   │
   7   │ Created by you
   8   │   #34108  add default main method for IDE launches [maxandersen:codestartmain]
   9   │   - Checks pending - Review required

notice how it says no pull request despite it reporting the same branch (since maxandersen is my branch) being in PR 34108

Activity

  1. samcoe commented on Jun 19, 2023

    @samcoe
    Contributor

    @maxandersen If you run gh repo set-default --view are you seeing the repo where the PR was created? If not you may just need to change the default repo using gh repo set-default. gh pr view only searches the current default repo for pull requests associated with a branch, not across all known git remotes.

  2. added
    more-info-neededMore info needed from user/contributor
    and removed on Jun 19, 2023
  3. samcoe commented on Sep 1, 2023

    @samcoe
    Contributor

    Closing due to lack of response from author.

  4. maxandersen commented on Sep 1, 2023

    @maxandersen
    Author

    sorry - I missed the comment while I was on pto.

    it says:

    gh repo set-default --view
    quarkusio/quarkus
    

    which is the expected default.

    and gh pr status still reports no pr despite it lists it:

    Relevant pull requests in quarkusio/quarkus
       
       Current branch
         There is no pull request associated with [codestartmain]
       Created by you
                 #34108  add default main method for IDE launches [maxandersen:codestartmain]
                 × 4/46 checks failing + Changes requested
    
  5. reopened this on Sep 6, 2023
  6. samcoe commented on Sep 6, 2023

    @samcoe
    Contributor

    @maxandersen Thanks for responding. I am still unsure as to why this is happening. Could you rerun the command but this time set the GH_DEBUG=api environment variable? This will output more logs for us to use for debugging. Please sanitize the logs of any personal information before posting them here.

  7. williammartin commented on Jan 16, 2024

    @williammartin
    Member

    Closing this due to inactivity but feel free to reopen if it's still an issue and we can move it forward.

  8. maxandersen commented on Jan 17, 2024

    @maxandersen
    Author

    I just got back to this today - same issue with same pr.

    Here is gist with debug output https://gist.github.com/maxandersen/76374e5672ff4fdd787e5a915563ba6a

    so yes, still happens.

  9. 29 remaining items

  10. brettchalupa commented on Feb 13, 2025

    @brettchalupa

    @williammartin That did it, thanks! It's working well now. I also set this:

    [push]
    	autoSetupRemote = true
    

    to keep the workflow pretty similar. I really appreciate the debugging help here.

  11. williammartin commented on Feb 13, 2025

    @williammartin
    Member

    No problem, I appreciate your quick responses.

  12. scarf005 commented on Apr 30, 2025

    @scarf005
    Contributor

    hi, I'm stumbling into same issue frequently when attempting to merge PRs after I gh pr checkout, this time with cataclysmbn/Cataclysm-BN#6465.

    $ git --version
    git version 2.49.0
    $ gh version 2.31.0-78-g9decb5d4 (2025-04-30)
    https://github.com/cli/cli/releases/latest
    $ uname -a
    Linux fedora 6.14.2-300.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Apr 10 21:50:55 UTC 2025 x86_64 GNU/Linux
    
    $ gh pr checkout 6465
    
    # approved PR in web UI
    
    $ gh pr merge
    no pull requests found for branch "firefox13:bike-saddle"

    Debug logs

    $ gh repo set-default --view
    cataclysmbnteam/Cataclysm-BN
    
    $ git config --get-regexp '^branch\.bike-saddle\.(remote|merge)$'
    branch.bike-saddle.remote Firefox13
    branch.bike-saddle.merge refs/heads/bike-saddle
    
    $ git config --get-regexp "^remote\..*\.gh-resolved$"
    remote.upstream.gh-resolved base
    
    $ git branch -vv | grep bike-saddle
    * bike-saddle                                                                   d9cb70b769f [Firefox13/bike-saddle] even less parts actually
    
    $ git config push.default
    current
    
    $ git rev-parse --abbrev-ref @{upstream}
    Firefox13/bike-saddle
    

    in .git/config:

    [branch "bike-saddle"]
    	remote = Firefox13
    	pushRemote = https://github.com/Firefox13/Cataclysm-BN.git
    	vscode-merge-base = origin/main
    	merge = refs/heads/bike-saddle
    	github-pr-owner-number = "cataclysmbnteam#Cataclysm-BN#6465"
    [remote "Firefox13"]
    	url = https://github.com/firefox13/cataclysm-bn
    	fetch = +refs/heads/*:refs/remotes/Firefox13/*
    	github-pr-remote = true
    
    
    remotes
    $ git remote -v
    DeltaEpsilon7787        https://github.com/deltaepsilon7787/cataclysm-bn (fetch)
    DeltaEpsilon7787        https://github.com/deltaepsilon7787/cataclysm-bn (push)
    Firefox13       https://github.com/firefox13/cataclysm-bn (fetch)
    Firefox13       https://github.com/firefox13/cataclysm-bn (push)
    Kaylakaze       https://github.com/kaylakaze/cataclysm-bn (fetch)
    Kaylakaze       https://github.com/kaylakaze/cataclysm-bn (push)
    KheirFerrum     https://github.com/kheirferrum/cataclysm-bn (fetch)
    KheirFerrum     https://github.com/kheirferrum/cataclysm-bn (push)
    NappingOcean    https://github.com/nappingocean/cataclysm-bn (fetch)
    NappingOcean    https://github.com/nappingocean/cataclysm-bn (push)
    Patternseeker   https://github.com/patternseeker/cataclysm-bn (fetch)
    Patternseeker   https://github.com/patternseeker/cataclysm-bn (push)
    RoyalFox2140    https://github.com/royalfox2140/cataclysm-bn (fetch)
    RoyalFox2140    https://github.com/royalfox2140/cataclysm-bn (push)
    chaosvolt       https://github.com/chaosvolt/cataclysm-bn (fetch)
    chaosvolt       https://github.com/chaosvolt/cataclysm-bn (push)
    killorank2      https://github.com/killorank2/cataclysm-bn (fetch)
    killorank2      https://github.com/killorank2/cataclysm-bn (push)
    origin  https://github.com/scarf005/Cataclysm-BN.git (fetch) [blob:none]
    origin  https://github.com/scarf005/Cataclysm-BN.git (push)
    shmakota        https://github.com/shmakota/cataclysm-bn (fetch)
    shmakota        https://github.com/shmakota/cataclysm-bn (push)
    upstream        https://github.com/cataclysmbnteam/Cataclysm-BN.git (fetch)
    upstream        https://github.com/cataclysmbnteam/Cataclysm-BN.git (push)
    usagirei        https://github.com/usagirei/cataclysm-bn (fetch)
    usagirei        https://github.com/usagirei/cataclysm-bn (push)
    
    GH_DEBUG=api gh pr list

    (irrelevant log truncated)

    GH_DEBUG=api gh pr list
    [git remote -v]
    [git config --get-regexp ^remote\..*\.gh-resolved$]
    * Request at 2025-04-30 22:27:51.385265297 +0900 KST m=+0.046356509
    * Request to https://api.github.com/graphql
    > POST /graphql HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token ████████████████████
    > Content-Length: 958
    > Content-Type: application/json; charset=utf-8
    > Graphql-Features: merge_queue
    > User-Agent: GitHub CLI 2.65.0
    
    GraphQL query:
    fragment pr on PullRequest{number,title,state,url,headRefName,headRepositoryOwner{id,login,...on User{name}},isCrossRepository,isDraft,createdAt}
        query PullRequestList(
          $owner: String!,
          $repo: String!,
          $limit: Int!,
          $endCursor: String,
          $baseBranch: String,
          $headBranch: String,
          $state: [PullRequestState!] = OPEN
        ) {
          repository(owner: $owner, name: $repo) {
            pullRequests(
              states: $state,
              baseRefName: $baseBranch,
              headRefName: $headBranch,
              first: $limit,
              after: $endCursor,
              orderBy: {field: CREATED_AT, direction: DESC}
            ) {
              totalCount
              nodes {
                ...pr
              }
              pageInfo {
                hasNextPage
                endCursor
              }
            }
          }
        }
    GraphQL variables: {"limit":30,"owner":"cataclysmbnteam","repo":"Cataclysm-BN","state":["OPEN"]}
    
    < HTTP/2.0 200 OK
    < Access-Control-Allow-Origin: *
    < Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
    < Content-Security-Policy: default-src 'none'
    < Content-Type: application/json; charset=utf-8
    < Date: Wed, 30 Apr 2025 13:27:51 GMT
    < Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
    < Server: github.com
    < Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
    < Vary: Accept-Encoding, Accept, X-Requested-With
    < X-Accepted-Oauth-Scopes: repo
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: deny
    < X-Github-Media-Type: github.v4; param=merge-info-preview.nebula-preview; format=json
    < X-Github-Request-Id: CC10:18DD1:14579:1D8FF:68122557
    < X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
    < X-Oauth-Scopes: gist, read:org, repo, workflow
    < X-Ratelimit-Limit: 5000
    < X-Ratelimit-Remaining: 4827
    < X-Ratelimit-Reset: 1746021505
    < X-Ratelimit-Resource: graphql
    < X-Ratelimit-Used: 173
    < X-Xss-Protection: 0
    
    {
      "data": {
        "repository": {
          "pullRequests": {
            "totalCount": 27,
            "nodes": [
              {
                "number": 6465,
                "title": "feat: craftable bike saddles",
                "state": "OPEN",
                "url": "https://github.com/cataclysmbnteam/Cataclysm-BN/pull/6465",
                "headRefName": "bike-saddle",
                "headRepositoryOwner": {
                  "id": "MDQ6VXNlcjU3ODEwMzAx",
                  "login": "Firefox13",
                  "name": null
                },
                "isCrossRepository": true,
                "isDraft": false,
                "createdAt": "2025-04-30T12:25:15Z"
              },
             
            ],
            "pageInfo": {
              "hasNextPage": false,
              "endCursor": "Y3Vyc29yOnYyOpK5MjAyMi0wNi0wNFQwMzozODo1NiswOTowMM45FfI7"
            }
          }
        }
      }
    }
    
    * Request took 747.722482ms
    
    Showing 27 of 27 open pull requests in cataclysmbnteam/Cataclysm-BN
    
    ID     TITLE                                       BRANCH                                     CREATED AT         
    #6465  feat: craftable bike saddles                Firefox13:bike-saddle                      about 1 hour ago
    
    GH_DEBUG=api gh pr view -w
    [git remote -v]
    [git config --get-regexp ^remote\..*\.gh-resolved$]
    [git symbolic-ref --quiet HEAD]
    [git config --get-regexp ^branch\.bike-saddle\.(remote|merge)$]
    [git remote -v]
    [git config --get-regexp ^remote\..*\.gh-resolved$]
    * Request at 2025-04-30 23:11:21.80009367 +0900 KST m=+0.043364183
    * Request to https://api.github.com/graphql
    > POST /graphql HTTP/1.1
    > Host: api.github.com
    > Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
    > Authorization: token ████████████████████
    > Content-Length: 586
    > Content-Type: application/json; charset=utf-8
    > Graphql-Features: merge_queue
    > Time-Zone: Asia/Seoul
    > User-Agent: GitHub CLI v2.31.0-78-g9decb5d4
    
    GraphQL query:
    query PullRequestForBranch($owner: String!, $repo: String!, $headRefName: String!, $states: [PullRequestState!]) {
        repository(owner: $owner, name: $repo) {
          pullRequests(headRefName: $headRefName, states: $states, first: 30, orderBy: { field: CREATED_AT, direction: DESC }) {
            nodes {url,id,number,state,baseRefName,headRefName,isCrossRepository,headRepositoryOwner{id,login,...on User{name}}}
          }
          defaultBranchRef { name }
        }
      }
    GraphQL variables: {"headRefName":"bike-saddle","owner":"cataclysmbnteam","repo":"Cataclysm-BN","states":null}
    
    < HTTP/2.0 200 OK
    < Access-Control-Allow-Origin: *
    < Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
    < Content-Security-Policy: default-src 'none'
    < Content-Type: application/json; charset=utf-8
    < Date: Wed, 30 Apr 2025 14:11:22 GMT
    < Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
    < Server: github.com
    < Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
    < Vary: Accept-Encoding, Accept, X-Requested-With
    < X-Accepted-Oauth-Scopes: repo
    < X-Content-Type-Options: nosniff
    < X-Frame-Options: deny
    < X-Github-Media-Type: github.v4; param=merge-info-preview.nebula-preview; format=json
    < X-Github-Request-Id: 8504:2846E2:3ECD5:58E03:68122F89
    < X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
    < X-Oauth-Scopes: gist, read:org, repo, workflow
    < X-Ratelimit-Limit: 5000
    < X-Ratelimit-Remaining: 4986
    < X-Ratelimit-Reset: 1746025413
    < X-Ratelimit-Resource: graphql
    < X-Ratelimit-Used: 14
    < X-Xss-Protection: 0
    
    {
      "data": {
        "repository": {
          "pullRequests": {
            "nodes": [
              {
                "url": "https://github.com/cataclysmbnteam/Cataclysm-BN/pull/6465",
                "id": "PR_kwDOAWjecM6UfvLg",
                "number": 6465,
                "state": "OPEN",
                "baseRefName": "main",
                "headRefName": "bike-saddle",
                "isCrossRepository": true,
                "headRepositoryOwner": {
                  "id": "MDQ6VXNlcjU3ODEwMzAx",
                  "login": "Firefox13",
                  "name": null
                }
              }
            ]
          },
          "defaultBranchRef": {
            "name": "main"
          }
        }
      }
    }
    
    * Request took 1.762983161s
    no pull requests found for branch "firefox13:bike-saddle"
    
  13. williammartin commented on Apr 30, 2025

    @williammartin
    Member

    @scarf005 happy to help you but before diving in I'd like to clear up your gh version. You said:

    $ gh version 2.31.0-78-g9decb5d4 (2025-04-30)

    Did you build this yourself? The date is today but 2.31.0 is nearly 2 years old.

  14. scarf005 commented on Apr 30, 2025

    @scarf005
    Contributor

    @williammartin
    oops, forgot to make fork track upstream/trunk.

    gh version 2.71.2-14-gf6dd6997 (2025-04-30)
    https://github.com/cli/cli/releases/latest

    that being said, issue doesn't happen in trunk, turns out the fedora 41 shipped with outdated github CLI. must've been solved in recent commits.

    Name            : gh
    Epoch           : 0
    Version         : 2.65.0
    Release         : 1.fc41
    Architecture    : x86_64
    Installed size  : 42.6 MiB
    Source          : gh-2.65.0-1.fc41.src.rpm
    From repository : <unknown>
    Summary         : GitHub's official command line tool
    URL             : https://github.com/cli/cli
    License         : Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unlicense
    Description     : A command-line interface to GitHub for use in your terminal or your scripts.
                    : 
                    : gh is a tool designed to enhance your workflow when working with GitHub. It
                    : provides a seamless way to interact with GitHub repositories and perform various
                    : actions right from the command line, eliminating the need to switch between your
                    : terminal and the GitHub website.
    Vendor          : Fedora Project
    
  15. BagToad commented on Apr 30, 2025

    @BagToad
    Member

    👋 @scarf005 - yes, we made a lot of changes to PR resolution in recent versions :)

    @williammartin I wonder if we can close this issue?

  16. scarf005 commented on May 13, 2025

    @scarf005
    Contributor

    EDIT: This bug happened because GitHub repository URL redirects are case-insensitive, while gh pr status is case-sensitive. After fixing the case in the remote definition within .git/config, it now works correctly. I don't exactly remember why the lowercase name was inserted in the first place, tho.

     [remote "NappingOcean"]
    -	url = https://github.com/nappingocean/cataclysm-bn
    +	url = https://github.com/NappingOcean/cataclysm-bn
     	fetch = +refs/heads/*:refs/remotes/NappingOcean/*
     	github-pr-remote = true

    @BagToad hit the same issue today again (tested on trunk):

    📦[scarf@fedora Cataclysm]> gh --version
    gh version 2.72.0-77-g17af24e1 (2025-05-14)
    https://github.com/cli/cli/releases/latest
    📦[scarf@fedora Cataclysm]> gh pr-merge
    ⣟PR 6530: feat: allow choosing color of uilist entry in Lua
      Base: main
      Head: fix-lua-uilist-entry-color
      isNotClosedOrMergedWhenHeadIsDefault: true
    headMatches: NappingOcean:fix-lua-uilist-entry-color == nappingocean:fix-lua-uilist-entry-color, baseMatches: main == Empty
    no pull requests found for branch "nappingocean:fix-lua-uilist-entry-color"
    
    Details
    diff --git a/Makefile b/Makefile
    index 32a06df2..48945d8a 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -74,7 +74,7 @@ endif
     ## Install/uninstall tasks are here for use on *nix platform. On Windows, there is no equivalent.
     
     DESTDIR :=
    -prefix  := /usr/local
    +prefix  ?= /usr/local
     bindir  := ${prefix}/bin
     datadir := ${prefix}/share
     mandir  := ${datadir}/man
    diff --git a/pkg/cmd/pr/shared/find_refs_resolution.go b/pkg/cmd/pr/shared/find_refs_resolution.go
    index e4e51bab..3f2376af 100644
    --- a/pkg/cmd/pr/shared/find_refs_resolution.go
    +++ b/pkg/cmd/pr/shared/find_refs_resolution.go
    @@ -106,6 +106,9 @@ func (r PRFindRefs) UnqualifiedHeadRef() string {
     func (r PRFindRefs) Matches(baseBranchName, qualifiedHeadRef string) bool {
     	headMatches := qualifiedHeadRef == r.QualifiedHeadRef()
     	baseMatches := r.baseBranchName.IsNone() || baseBranchName == r.baseBranchName.Unwrap()
    +
    +	fmt.Printf("headMatches: %s == %s, baseMatches: %s == %s\n", qualifiedHeadRef, r.QualifiedHeadRef(), baseBranchName, r.baseBranchName.UnwrapOr("Empty"))
    +
     	return headMatches && baseMatches
     }
     
    diff --git a/pkg/cmd/pr/shared/finder.go b/pkg/cmd/pr/shared/finder.go
    index b8d23c97..09bafc1d 100644
    --- a/pkg/cmd/pr/shared/finder.go
    +++ b/pkg/cmd/pr/shared/finder.go
    @@ -406,6 +406,11 @@ func findForRefs(httpClient *http.Client, prRefs PRFindRefs, stateFilters, field
     		// When the head is the default branch, it doesn't really make sense to show merged or closed PRs.
     		// https://github.com/cli/cli/issues/4263
     		isNotClosedOrMergedWhenHeadIsDefault := pr.State == "OPEN" || resp.Repository.DefaultBranchRef.Name != prRefs.QualifiedHeadRef()
    +
    +		fmt.Printf("PR %d: %s\n", pr.Number, pr.Title)
    +		fmt.Printf("  Base: %s\n", pr.BaseRefName)
    +		fmt.Printf("  Head: %s\n", pr.HeadRefName)
    +		fmt.Printf("  isNotClosedOrMergedWhenHeadIsDefault: %t\n", isNotClosedOrMergedWhenHeadIsDefault)
     		if prRefs.Matches(pr.BaseRefName, pr.HeadLabel()) && isNotClosedOrMergedWhenHeadIsDefault {
     			return &pr, nil
     		}

    apparently gh pr checkout lowercases remote name and this causes check in

    headMatches := qualifiedHeadRef == r.QualifiedHeadRef()

    to fail.

  17. jsoref commented on Oct 20, 2025

    @jsoref
    Contributor

    There might be a case thing, but what I've seen (I'm using a debugger)

    if prRefs.Matches(pr.BaseRefName, pr.HeadLabel()) && isNotClosedOrMergedWhenHeadIsDefault {

    calls:

    headMatches := qualifiedHeadRef == r.QualifiedHeadRef()

    qualifiedHeadRef = "jsoref:give-mnt-to-container-as-tmp"

    // QualifiedHeadRef returns a stringified form of the head ref, varying depending
    // on whether the head ref is in the same repository as the base ref. If they are
    // the same repository, we return the branch name only. If they are different repositories,
    // we return the owner and branch name in the form <owner>:<branch>.
    func (r PRFindRefs) QualifiedHeadRef() string {
    return r.qualifiedHeadRef.String()

    r.qualifiedHeadRef = "give-mnt-to-container-as-tmp"

    So, headMatches = false


    I have code that works for this.

  18. added a commit that references this issue on Mar 24, 2026
    c6912a1
  19. cli-triage commented on Jul 9, 2026

    @cli-triage

    This is a confirmed bug (already labeled) in how gh pr status detects PRs opened from fork branches. I'm suggesting priority-3 because a workaround exists (specifying the PR number directly, e.g. gh pr view 34108) and the issue affects fork-based PR workflows rather than all users. Note that issue #12203 (open, filed in 2025) appears to be a duplicate of this one - it describes the identical symptom after gh pr checkout from a fork, and references the related closed issue #5914.

    Generated by Issue Triage (skills-driven) · 21.6 AIC · ⌖ 6.2 AIC · ⊞ 5K · ◷

  20. BagToad commented on Jul 9, 2026

    @BagToad
    Member

    As a matter of housekeeping, I'm going to close this out in favour of #12203 which seems to have a bit more recent investigation in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr command

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions