git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug: `git remote show <remote>` reports different HEAD branch than refs/remotes/<remote>/HEAD

From
Jason Karns <jason.karns@gmail.com>
Date
Aug 15, 2017, 14:26 UTC
Message-ID
<CAKNmmv3_K4gB6FbcmAjXyviMbU2Ts7Rh7txkOof+-36rF_1+Gw@mail.gmail.com>

I have a git repo that shows a different branch in `.git/refs/remotes/origin/HEAD` than is reported by `git remote show origin`.

The branch is `github-rename` in refs/remotes/origin/HEAD, but shows `master` in output of git-remote-show

``` $ cat .git/refs/remotes/origin/HEAD ref: refs/remotes/origin/github-rename

$ git remote show origin
* remote origin
  Fetch URL: git@XXXX.git
  Push  URL: git@XXXX.git
  HEAD branch: master
  Remote branches:
    github-rename     tracked
    master            tracked
    qa                tracked
    refactor-test     tracked
  Local branches configured for 'git pull':
    github-rename merges with remote github-rename
    master        merges with remote master
  Local refs configured for 'git push':
    github-rename pushes to github-rename (up to date)
    master        pushes to master        (up to date)
```
git version 2.14.1
Background:

Prior to my repo being cloned, the default branch was configured to be `some-random-branch` on github. My repo was cloned and the HEAD branch was set to `some-random-branch` correctly (in `refs/`). However, git-remote-show reported `master` as the HEAD branch.

Later, `some-random-branch` was deleted from the remote. It _remained_ as the HEAD branch locally according to `refs/`.

In order to test the remote-show command, I changed the HEAD branch to a branch that actually existed by running `git remote set-head origin github-rename`. It changed the HEAD branch in `refs/` but remote-show continues to report `master` as the remote's HEAD.

Thanks, Jason Karns

Next: Igor Djordjevic
Message 1 of 4 in “Bug: `git remote show <remote>` reports different HEAD branch than refs/remotes/<remote>/HEAD”
  1. Jason KarnsAug 15, 2017
  2. Igor DjordjevicAug 15, 2017
  3. Jason KarnsAug 15, 2017
  4. Jeff KingAug 15, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.