README.md in blank suggests force push to main, which is disabled
Summary
The standard README.md file in a blank repository contains the instruction to force push from an existing repository with
git push -uf origin main
Force pushing to the main branch is disabled by default so this command fails.
Steps to reproduce
- Initialize a git repository, add a file and commit.
- Create a new project
- Choose "Create blank project"
- Don't untick "Initialize repository with a README". Add a "Project name" and click "Create Project".
- Follow the instructions in upload the files created in the first step
Example Project
https://gitlab.com/rantahar/test_new_project/
What is the current bug behavior?
Following the instructions to upload an existing repository, the command to git push -uf origin main fails.
What is the expected correct behavior?
Uploading an existing repository following the instructions should succeed.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Results of GitLab application Check
Possible fixes
The problem is in https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/views/projects/readme_templates/default.md.tt
Options I can think of:
- Add instructions to allow a force push
- Instead instruct the user to create a repository without a README.md
For solution 1, add something like:
Go to Settings -> Repository, expand the section "Protected branches". The table of protected branches should contain the "main" branch. Click on the "Allowed to force push" slider to enable force pushes. You may want to disable this after the next step.