cli / cli/cli

'gh pr create' leaves new remote without refs/remotes/<remote>/HEAD

Open
#13,286 1 comment 0 reactions 0 assignees View on GitHub
bug gh-pr priority-3 stale
Dominant language
Go
Stars
46.3k
Forks
9k
Avg merge
2d 9h
Merged PRs (30d)
89

Description

### Describe the bug

After gh pr create auto-forks (or gh repo fork --remote), the new origin remote has no refs/remotes/origin/HEAD. This breaks tools and shorthands that rely on origin/HEAD resolving (e.g. git rev-parse origin, IDEs showing the default branch). Both code paths should run git fetch and git remote set-head -a after adding the remote.

### Affected version

```
gh version 2.63.1 (2024-12-03)
https://github.com/cli/cli/releases/tag/v2.63.1
```

### Steps to reproduce the behavior

1. Type this 'gh pr create'
2. View the output 'git log origin'
3. See error

### Expected vs actual behavior

Expected:

To be able to use the 'origin' shorthand for the forked repo, which I can use for the original cloned remote (which has now been renamed 'upstream').

Actual:

```
fatal: ambiguous argument 'origin'
```

### Logs

```
❯ git log origin
fatal: ambiguous argument 'origin': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.