Skip to content

gh repo list --no-archived impacts sorting for non-default branch pushes #13881

Open

Agent suggestions

Public preview

Description

@bburns-ds

Describe the bug

Briefly: gh repo list sorts by most recent update to any branch, while gh repo list --no-archived sorts by most recent update to the default branch only, but both display the date of the most recent update to any branch, leading to confusing behavior.

After pushing a commit to a non-default branch, gh repo list correctly moves the repository to the top based on its displayed UPDATED value. However, gh repo list --no-archived displays the same, correct UPDATED value, but the item appears in the same position it appeared in before the new commit.

Consequently, the --no-archived output is not sorted by the UPDATED values it displays, which is inconsistent with the default behavior of gh repo list. Notably, the sorting places the repo based on the last update to the repo's default branch.

Affected version

gh version 2.96.0 (2026-07-02)
https://github.com/cli/cli/releases/tag/v2.96.0

Steps to reproduce the behavior

  1. Fork cli/scoop-gh.
  2. Clone the fork.
  3. Create a non-default branch named test.
  4. Make and commit a change on test.
  5. Push test to the fork.
  6. Run gh repo list.
  7. Run gh repo list --no-archived.
  8. Compare the position of scoop-gh in the two outputs.

Expected vs actual behavior

I expect gh repo list to have the same sorting with and without the --no-archived flag, but for the archived entries to just drop from the list.

gh repo list behaves as expected, sorting by UPDATED. gh repo list --no-archived has unexpected behavior, displaying UPDATED correctly but instead appears to sort repos by UPDATED for the default branch (not displayed).

Logs

Unrelated repositories have been omitted. Two unrelated repository names and their descriptions have also been anonymized.

...  # fork is made

❯ gh repo list

Showing 7 of 7 repositories in @bburns-ds

NAME                  DESCRIPTION                                      INFO          UPDATED
bburns-ds/repo1                                                        private       about 27 days ago
bburns-ds/repo2                                                        private       about 7 months ago
bburns-ds/scoop-gh    [DEPRECATED] scoop packaging for the github cli  public, fork  about 3 years ago

❯ gh repo list --no-archived

Showing 7 of 7 repositories in @bburns-ds

NAME                  DESCRIPTION                                      INFO          UPDATED
bburns-ds/repo1                                                        private       about 27 days ago
bburns-ds/repo2                                                        private       about 7 months ago
bburns-ds/scoop-gh    [DEPRECATED] scoop packaging for the github cli  public, fork  about 3 years ago

...  # repo is cloned, branch is made, commit is made on branch, change is pushed

❯ gh repo list

Showing 24 of 24 repositories in @bburns-ds

NAME                  DESCRIPTION                                      INFO          UPDATED
bburns-ds/scoop-gh    [DEPRECATED] scoop packaging for the github cli  public, fork  less than a minute ago
bburns-ds/repo1                                                        private       about 27 days ago
bburns-ds/repo2                                                        private       about 7 months ago

❯ gh repo list --no-archived

Showing 7 of 7 repositories in @bburns-ds

NAME                  DESCRIPTION                                      INFO          UPDATED
bburns-ds/repo1                                                        private       about 27 days ago
bburns-ds/repo2                                                        private       about 7 months ago
bburns-ds/scoop-gh    [DEPRECATED] scoop packaging for the github cli  public, fork  less than a minute ago

Activity

  1. cli-triage commented on Jul 14, 2026

    @cli-triage

    This looks like a confirmed bug: gh repo list --no-archived uses a different sort key (last update to the default branch) than gh repo list (last update to any branch), even though both commands display the same UPDATED value (any-branch). The result is that --no-archived output appears sorted inconsistently with the timestamps shown. I'm suggesting bug and priority-3 — it's a real behavioral inconsistency with clear reproduction steps, but it doesn't prevent core functionality and a workaround exists (omit --no-archived and filter manually). No duplicates were found for this specific issue.

    Generated by Issue Triage (skills-driven) for #13881 · 19.1 AIC · ⌖ 3.98 AIC · ⊞ 5.1K · ◷

  2. babakks commented on Jul 22, 2026

    @babakks
    Member

    Thanks for reporting this, @bburns-ds! 🙏

    The root cause is repo list uses a different GraphQL query (i.e. search) when certain flags (like --no-archived) are provided:

    • gh repo list: (note the ordering: orderBy: { field: PUSHED_AT, direction: DESC })
      query RepositoryList($perPage:Int!,$endCursor:String,$privacy:RepositoryPrivacy,$fork:Boolean) {
          repositoryOwner: viewer {
            login
            repositories(first: $perPage, after: $endCursor, privacy: $privacy, isFork: $fork, ownerAffiliations: OWNER, orderBy: { field: PUSHED_AT, direction: DESC }) {
              nodes{nameWithOwner,description,isPrivate,isFork,isArchived,createdAt,pushedAt,visibility}
              totalCount
              pageInfo{hasNextPage,endCursor}
            }
          }
      }
    • gh repo list --no-archived: (note the ordering: sort:updated-desc)
      query RepositoryListSearch($query:String!,$perPage:Int!,$endCursor:String) {
          search(type: REPOSITORY, query: $query, first: $perPage, after: $endCursor) {
            repositoryCount
            nodes{...on Repository{nameWithOwner,description,isPrivate,isFork,isArchived,createdAt,pushedAt,visibility}}
            pageInfo{hasNextPage,endCursor}
          }
        }
      GraphQL variables: {"perPage":30,"query":"sort:updated-desc archived:false fork:true user:@me"}

    So, this confirms your observations.


    I know it can be confusing but I'm not really comfortable with adjusting this behaviour, as it's been there for a long time and changing it could breaking for users who rely on either orderings.

    Before closing this, can you please share more about your workflow and tell me about how this ordering issue affects your experience? It'd be helpful if we have more context.

  3. added
    more-info-needed
    gh-repo
    on Jul 22, 2026
  4. williammartin commented on Jul 22, 2026

    @williammartin
    Member

    @babakks if we're concerned about backwards compatability, could we support a flag to allow stable results? It can be achieved with --jq but that's a lot of extra complexity for anyone.

  5. babakks commented on Jul 22, 2026

    @babakks
    Member

    Yeah, that's what I was thinking about and checked API support around it. The problem is user.repositories query supports both pushed-at and updated-at, but the search query's sort: qualifier doesn't seem to have a documented pushed-at (checked via GUI autocomplete suggestions).

  6. bburns-ds commented on Jul 22, 2026

    @bburns-ds
    Author

    @babakks hey thanks for checking this out.

    I know it can be confusing but I'm not really comfortable with adjusting this behaviour, as it's been there for a long time and changing it could breaking for users who rely on either orderings.

    this makes sense to me

    Before closing this, can you please share more about your workflow and tell me about how this ordering issue affects your experience? It'd be helpful if we have more context.

    I am not scripting with this or using it as a subroutine. I default to using --no-archived because I aggressively archive repos and dislike that archived repos are shown in the GitHub website repo list by default / don't want to have to filter every time. However, because I am mostly pushing to branches and PRing in, it's just unintuitive to me that if I push then gh repo list that what I just pushed to might not even appear because it might be outside the limit I set / filter.

    I recognize that it's better to not break what existing (more power-y) users are doing and so recognize that it's probably best to keep the existing fork in behavior.

  7. removed
    more-info-needed
    on Jul 22, 2026
  8. babakks commented on Jul 24, 2026

    @babakks
    Member

    Thanks for sharing, @bburns-ds! 🙏

    An optional flag to explicitly selecting the ordering would be a good addition, but as I mentioned there's no documented option for sort by pushed-at when using the search query from GraphQL (docs).

    So, I'm labelling this as an enhancement request blocked by platform capabilities.

  9. added
    enhancement
    platform
    on Jul 24, 2026
  10. github-actions commented on Jul 24, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  11. removed
    needs-triage
    on Jul 24, 2026
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

    blockedenhancementgh-repoplatformstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions