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

bug - Inconsistency of git status and branch, ./git/branches and ./git/HEAD

From
IGIrina Gulina <igulina@redhat.com>
Date
Sep 30, 2023, 06:51 UTC
Message-ID
<CAAcHogVu+jrLdtEZi+Jx9d9gM5BvUF_nRVKEc4BsWCxCanL9Uw@mail.gmail.com>

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
1. create an empty directory in CLI: mkdir test_repo
2. convert it to a git directory: cd test_repo & git init
3. 'git status' will say you are "On branch master"
4. 'git branch', 'git branch --all', or 'git branch --list' - nothing
will say the master branch exists. And per man pages definition the
branch command displays existing branches. So the question is why 'git
status' says "On branch master", but 'git branches' don't?
5. check on 'ls -la ./git/branches' - it's empty
6. check on 'ls -la ./git/refs/heads' - it's empty
7. check on 'cat ./git/HEAD' - it shows 'ref: refs/heads/master' -
why? if we didn't create any commit, and no branch exists?

What did you expect to happen? (Expected behavior) git status should not say "On branch master", cat ./git/HEAD should be empty. Or the master branch should be created in ./git/branches and the 'git branch' command should display it.

What happened instead? (Actual behavior) Inconsistency between 'git status', 'git branch', ./git/branches and ./git/HEAD

What's different between what you expected and what actually happened?
Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.41.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.4.12-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 23 17:46:49 UTC 2023 x86_64 compiler info: gnuc: 13.1 libc info: glibc: 2.37 $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]
Next: Irina Gulina
Message 1 of 5 in “bug - Inconsistency of git status and branch, ./git/branches and ./git/HEAD”
  1. Irina GulinaSep 30, 2023
  2. Irina GulinaSep 30, 2023
  3. Junio C HamanoSep 30, 2023
  4. Chris TorekSep 30, 2023
  5. Chris TorekSep 30, 2023

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.