15

I've installed Gitea, and every time I create a new repository it defaults the master branch name to "main", which I find a bit annoying.

Is there a way to make it default back to the normal "master" naming convention? If so how do I do this?

FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
  • Note that the "normal" branch is not necessarily `master`. The new normal on [GitHub](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch), [GitLab](https://docs.gitlab.com/ee/user/project/repository/branches/default.html) and also Gitea is `main`. – Corbie May 08 '23 at 07:27
  • 4
    @Corbie I always change it back to master, because that's the best name for the master branch – FreelanceConsultant May 09 '23 at 07:36
  • Why is `master` better than `main`? If you branch from it, why not use `trunk` (like subversion)? CVS used `MAIN`, so this name is older than git. – Corbie May 14 '23 at 07:03
  • 1
    @Corbie Master is a word which has meaning. Master branch. Master bus. Master drive. Its use dates back nearly a century in engineering, possibly more than a century. I first encountered it as a child in the context of master and slave jumpers on hard disks. It has been the master branch in Git since Git first existed. So obviously, since it has been this way for all of time, and Gitea is an interface to Git, the default should obviously be master, not main. – FreelanceConsultant May 14 '23 at 13:40
  • So "master" is the best name, because "we've always done it this way". Always the best reason for doing things. Grace Hopper knew it, again. – Corbie May 22 '23 at 05:59
  • 1
    @Corbie Should we change the meaning of "Dog" to "Cat" in the English language as well? Will that improve or hinder productivity? Of course, it is obvious. We *should* change the meaning of "Dog" to "Cat" because I personally find it easier to type cat than dog on my keyboard. – FreelanceConsultant May 22 '23 at 11:09
  • You realize, that there is a reason for using `main` instead of `master` other than because it's shorter, do you? Did you miss the whole discussion in 2020? – Corbie Jun 07 '23 at 14:02
  • 1
    @Corbie I didn't realize Gitea had personally written to me about the issue in 2020 – FreelanceConsultant Jun 07 '23 at 15:14

2 Answers2

13

When is your version of gitea changing 'master' to 'main' it should also support configuration value DEFAULT_BRANCH under the Repository section of init file. More details could be found in official documentation

raliscenda
  • 426
  • 6
  • 11
  • Put `DEFAULT_BRANCH = master` under the section `[repository]` of the file `/etc/gitea/app.ini`. (The file may be in a different location on your system. I followed the binary install instructions, working on Debian 11. – FreelanceConsultant Sep 26 '22 at 08:51
6

If modifying the ini config (conf/app.ini) file:

# ...
[repository]
DEFAULT_BRANCH = master
# ...

If you happen to be running in a Docker Compose (docker-compose.yml) setup:

version: '3'
services:
  gitea:
    image: gitea/gitea:latest
    # ...
    environment:
      - GITEA__repository__DEFAULT_BRANCH=master
      # ...
  • Note these are missing all the other settings that are probably needed, just showing where to put the ENV Variable.
jojobyte
  • 61
  • 4