HEAD is not set to alternative default brach when using a template #6488

Closed
opened 2025-11-02 06:57:30 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @kb173 on GitHub (Dec 9, 2020).

  • Gitea version (or commit ref): 1.14.0+dev-290-gb1cf7f4df built with GNU Make 4.3, go1.15.5 : bindata, timetzdata, sqlite, sqlite_unlock_notify
  • Git version: 2.26.2
  • Operating system: 18.04.5 LTS

I am running Gitea using Docker, using the (slightly modified) docker-compose.yaml.

Description

I created a template repository whose default branch is named "main" instead of "master". When I create a new repository from this template, ticking "Git Content (Default Branch)", the HEAD is set incorrectly on the server:

When cloning, I get the notice "warning: remote HEAD refers to nonexistent ref, unable to checkout.". I get placed in the non-existent master branch and I need to manually checkout the main branch in order to access the files in the repository.

Upon inspection of the HEAD on the remote (in the Gitea repository folder on the server, via SSH), I see that the HEAD is set wrongly. It is ref: refs/heads/master, but it should be ref: refs/heads/main. Manually editing this solves the issue for this repository.

Note that this is not the case in the template repository, only in the one instanced from this template.

I reproduced the issue in https://gitea.com/kb173/main-bug, which is instanced from the template https://gitea.com/kb173/template-default-main. As you can see, the web-UI correctly shows "main" as the only branch, but when cloning, the aforementioned warning occurs.

Seems to be related to https://github.com/go-gitea/gitea/issues/7601. While that is indeed fixed when creating a new repository from scratch, the problem seems to persist with repositories from templates.

Originally created by @kb173 on GitHub (Dec 9, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.14.0+dev-290-gb1cf7f4df built with GNU Make 4.3, go1.15.5 : bindata, timetzdata, sqlite, sqlite_unlock_notify - Git version: 2.26.2 - Operating system: 18.04.5 LTS <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> I am running Gitea using Docker, using the (slightly modified) docker-compose.yaml. - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (on https://gitea.com/, as I tried reproducing there before noticing this link: https://gitea.com/kb173/main-bug) - [ ] No ## Description I created a template repository whose default branch is named "main" instead of "master". When I create a new repository from this template, ticking "Git Content (Default Branch)", the HEAD is set incorrectly on the server: When cloning, I get the notice "warning: remote HEAD refers to nonexistent ref, unable to checkout.". I get placed in the non-existent master branch and I need to manually checkout the `main` branch in order to access the files in the repository. Upon inspection of the HEAD on the remote (in the Gitea repository folder on the server, via SSH), I see that the HEAD is set wrongly. It is `ref: refs/heads/master`, but it should be `ref: refs/heads/main`. Manually editing this solves the issue for this repository. Note that this is _not_ the case in the template repository, only in the one instanced from this template. I reproduced the issue in https://gitea.com/kb173/main-bug, which is instanced from the template https://gitea.com/kb173/template-default-main. As you can see, the web-UI correctly shows "main" as the only branch, but when cloning, the aforementioned warning occurs. Seems to be related to https://github.com/go-gitea/gitea/issues/7601. While that is indeed fixed when creating a new repository from scratch, the problem seems to persist with repositories from templates.
GiteaMirror added the type/bug label 2025-11-02 06:57:30 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6488