-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Create from template does not reference the right branch. #21994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I cannot reproduce it on v1.18.0. Are you sure that you found it on v1.18.0? The release time is after the time you opened this issue. You can find the exact version in the footer of any page. |
Just checked and the issue still remains, version is: |
Sorry, could you please point it out where's the problem? I don't see anything special in the example repo you give: And I also created a repo from your template, but I didn't see any warning when browsing or cloning it. |
Your repo seems to have the same problem.
It is that last line that is warning that the HEAD refers to a non-existent ref. When I try to pull changes, the problem becomes more obvious:
Git again complains here because we are not on a branch that exists on the origin. The UI also reflects this: See how the selection shows If you leave the template's default branch as |
Duplicated with #19470. |
Fix #21994. And fix #19470. While generating new repo from a template, it does something like "commit to git repo, re-fetch repo model from DB, and update default branch if it's empty". https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/modules/repository/generate.go#L241-L253 Unfortunately, when load repo from DB, the default branch will be set to `setting.Repository.DefaultBranch` if it's empty: https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/models/repo/repo.go#L228-L233 I believe it's a very old temporary patch but has been kept for many years, see: [2d2d85b](2d2d85bb#diff-1851799b06733db4df3ec74385c1e8850ee5aedee70b8b55366910d22725eea8) I know it's a risk to delete it, may lead to potential behavioral changes, but we cannot keep the outdated `FIXME` forever. On the other hand, an empty `DefaultBranch` does make sense: an empty repo doesn't have one conceptually (actually, Gitea will still set it to `setting.Repository.DefaultBranch` to make it safer).
Description
If you create a template with a different default branch (e.g. not 'main') and create another repository from that template, it sets the default branch to an empty reference to 'main' causing this error when cloning it
warning: remote HEAD refers to nonexistent ref, unable to checkout.
. This can be resolved by changing the default branch to the one from the template but that should be the default behavior or at least it should provide an option to specify the name of the branch.To reproduce:
Gitea Version
1.18.0
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Problem exists on both https://try.gitea.io/ and docker.
Database
No response
The text was updated successfully, but these errors were encountered: