Skip to content
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

Gitea remembers a non-existent default branch after the pushing source to remote with a different branch name #30627

Open
diamante0018 opened this issue Apr 21, 2024 · 2 comments
Labels

Comments

@diamante0018
Copy link

Description

Hello,
there is this visual bug on Gitea that does not happen when I do a similar process on GitHub/Gitlab.
In short, Gitea will remember the default branch name that was selected during repo creation after any branch is pushed instead of promoting the newly pushed branch to default.

On try.gitea.io I have created a new repository which contains some fork of mine from my self-hosted gitea.
g1d

By default Gitea will suggest me, the user, to use main as my default branch name. As a "clueless" user, I accept and proceed with the creation of the repo.

Now I have an empty repo on try.gitea.io. The default welcome page will tell me what to do next to push my already existing code to the remote.

git remote add origin https://try.gitea.io/diamante/zonetool.git
git push -u origin main

However, because in my scenario I am insisting on not using main I push a different branch to remote.

git remote add origin https://try.gitea.io/diamante/zonetool.git
git push -u origin develop

Here I push a branch called develop. This causes the following to happen:
prnew

Gitea is now convinced that I have pushed a new feature to a non-default branch and is proposing me to create a pull request. If I click that button it will lead me to:

https://try.gitea.io/diamante/zonetool/compare/main...develop

404

The page is 404 because the main branch never existed because I never pushed it

To fix my mistake I have to go to https://try.gitea.io/diamante/zonetool/settings/branches and edit the default branch name to suit my needs.

Desired behaviour/Bug fix:
Because this does not happen on other platforms like GitHub or so I think, like, I do this often and nothing of this sort ever happens to me, I'd like the same behaviour to happen on gitea as well. As in the first branch to be ever pushed is promoted to default and overrides user/default preference in repo "branches" settings.

cheers.

Gitea Version

1.23.0+dev-180-ge865de1e9d

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

https://try.gitea.io

Operating System

https://try.gitea.io

How are you running Gitea?

https://try.gitea.io

Database

None

@diamante0018
Copy link
Author

diamante0018 commented Apr 21, 2024

I tested this three other times on both try.gitea.io and my self-hosted instance and it does not always happen somehow?! This leaves me very perplexed as now I have no idea how to repro with 100% accuracy. It appears Gitea already has code to automatically promote to the default branch whatever gets pushed for the first time but does not always do it.

@yp05327
Copy link
Contributor

yp05327 commented Apr 22, 2024

So the problem is that the first pushed branch should be the default branch no matter what it has been set.
But sometimes, the default branch won't be changed.
Maybe there's some problems of sync DB and git files, as the default branch you see in settings page is saved in DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants