Error when creating new repo: branch does not have any commits #8410

Closed
opened 2025-11-02 08:05:10 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @mgray-online on GitHub (Jan 26, 2022).

Gitea Version

1.16.0+rc1

Git Version

2.30.2

Operating System

Ubuntu server 20.04.3 LTS

How are you running Gitea?

Running on docker, config file:

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1004
      - USER_GID=1005
      - GITEA__SERVER__DOMAIN=git.example.com
      - GITEA__SERVER__ROOT_URL=https://git.example.com
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=password
      - GITEA__mailer__ENABLED=true
      - GITEA__mailer__FROM=noreply@example.com
      - GITEA__mailer__MAILER_TYPE=smtp
      - GITEA__mailer__HOST=smtp.example.com:465
      - GITEA__mailer__IS_TLS_ENABLED=true
      - GITEA__mailer__USER=noreply@example.com
      - GITEA__mailer__PASSWD=password
      - GITEA__service__DEFAULT_BRANCH=main
      - GITEA__security__DISABLE_GIT_HOOKS=false
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /home/git/.ssh/:/data/git/.ssh
    ports:
      - "8095:3000"
      - "127.0.0.1:2222:22"
    depends_on:
      - db

  db:
    image: postgres:13
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - ./postgres:/var/lib/postgresql/data

Database

PostGres

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

https://gist.github.com/mmoomocow/6eb9413b0d756551ebe8b225a890e730

Description

I created a repo, and set the default branch to main
Then when attempting to view the repo it shows error 500 and the error appears in the logs.
Repo on demo site mmoomocow/test

Screenshots

image

Originally created by @mgray-online on GitHub (Jan 26, 2022). ### Gitea Version 1.16.0+rc1 ### Git Version 2.30.2 ### Operating System Ubuntu server 20.04.3 LTS ### How are you running Gitea? Running on docker, config file: ``` version: "3" networks: gitea: external: false services: server: image: gitea/gitea:latest container_name: gitea environment: - USER_UID=1004 - USER_GID=1005 - GITEA__SERVER__DOMAIN=git.example.com - GITEA__SERVER__ROOT_URL=https://git.example.com - GITEA__database__DB_TYPE=postgres - GITEA__database__HOST=db:5432 - GITEA__database__NAME=gitea - GITEA__database__USER=gitea - GITEA__database__PASSWD=password - GITEA__mailer__ENABLED=true - GITEA__mailer__FROM=noreply@example.com - GITEA__mailer__MAILER_TYPE=smtp - GITEA__mailer__HOST=smtp.example.com:465 - GITEA__mailer__IS_TLS_ENABLED=true - GITEA__mailer__USER=noreply@example.com - GITEA__mailer__PASSWD=password - GITEA__service__DEFAULT_BRANCH=main - GITEA__security__DISABLE_GIT_HOOKS=false restart: always networks: - gitea volumes: - ./gitea:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro - /home/git/.ssh/:/data/git/.ssh ports: - "8095:3000" - "127.0.0.1:2222:22" depends_on: - db db: image: postgres:13 restart: always environment: - POSTGRES_USER=gitea - POSTGRES_PASSWORD=password - POSTGRES_DB=gitea networks: - gitea volumes: - ./postgres:/var/lib/postgresql/data ``` ### Database PostGres ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist https://gist.github.com/mmoomocow/6eb9413b0d756551ebe8b225a890e730 ### Description I created a repo, and set the default branch to main Then when attempting to view the repo it shows error 500 and the error appears in the logs. Repo on demo site [mmoomocow/test](https://try.gitea.io/mmoomocow/test) ### Screenshots ![image](https://user-images.githubusercontent.com/44288823/151107562-cd1cf3e4-16c9-4f28-a368-b46668e9b9f8.png)
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 08:05:10 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Jan 26, 2022):

It's caused by hard-coded error string:

			strings.Contains(errbuf.String(), "fatal: your current branch 'master' does not have any commits yet") {

49dd906753/modules/git/repo.go (L81-L92)

@wxiaoguang commented on GitHub (Jan 26, 2022): It's caused by hard-coded error string: ``` strings.Contains(errbuf.String(), "fatal: your current branch 'master' does not have any commits yet") { ``` https://github.com/go-gitea/gitea/blob/49dd9067535538771ef13623ed1dd9698a4a2151/modules/git/repo.go#L81-L92
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8410