Thanks to visit codestin.com
Credit goes to github.com

Skip to content

support detached HEAD git state whenever applicable #1132

@metalogical

Description

@metalogical

Describe the bug

The way I use git is to stay in "detached HEAD," except when working on my own feature branches. For example, I don't keep a local master branch, and instead just refer to origin/master as necessary.

This breaks gh:

➜ gh --version
gh version DEV
https://github.com/cli/cli/releases/latest

➜ gh pr status
could not query for pull request for current branch: could not determine current branch: git: not on any branch

I built the tool via go install github.com/cli/cli/cmd/gh on the current latest commit (28f91cb).

Expected vs actual behavior

See above console output for actual behavior. What I expect is something like the following:

➜ gh pr status

Relevant pull requests in <REPO>

Current branch
  could not query for pull request for current branch: could not determine current branch: git: not on any branch

Created by you
  ...

Requesting a code review from you
  ...

Note that the error about not being on a branch is only relevant for the "current branch" section, so the gh tool should still output the other sections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions