Description
- Gitea version (or commit ref): 1.8.3
- Git version: 2.17.2
- Operating system: Amazon Linux 2
- Database (use
[x]
):- PostgreSQL
- MySQL
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gitea.io:
- Yes (https://try.gitea.io/vg-c/testdefaultbranch)
- No
- Not relevant
- Log gist:
Description
When a repository uses a default branch whose name is not "master", Gitea still maintains the .git/HEAD file with the content: "ref: refs/heads/master", and even if you try to explicitly set or update the default branch using the Settings/Branches page, it does not change the content of the HEAD file. Consequently, when you try to clone such a repository on your local machine, you get a warning from git: "warning: remote HEAD refers to nonexistent ref, unable to checkout." and then you have to explicitly checkout the default branch of the repository.
Exact steps to reproduce the issue are given below (tested and confirmed on https://try.gitea.io/vg-c/testdefaultbranch):
$ mkdir testdefaultbranch
$ cd testdefaultbranch
$ git init
$ touch README
$ git add README
$ git commit
$ git branch -m master newbranch
$ git branch -vv
- newbranch e2b1ee7 init commit
$ cat .git/HEAD
ref: refs/heads/newbranch
$ git remote add origin https://try.gitea.io/vg-c/testdefaultbranch.git
$ git push -u origin newbranch
...
Counting objects: 3, done.
Writing objects: 100% (3/3), 192 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://try.gitea.io/vg-c/testdefaultbranch.git
- [new branch] newbranch -> newbranch
Branch newbranch set up to track remote branch newbranch from origin.
$ cd ..
$ mkdir t
$ cd t
$ git clone https://try.gitea.io/vg-c/testdefaultbranch.git
Cloning into 'testdefaultbranch'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ cat testdefaultbranch/.git/HEAD
ref: refs/heads/master