Problem with GitHub template repository when I include all branches

I have a template repository on GitHub with 3 branches: master, develop and feature/auth and the reason for that is because the code of the branch feature/auth is optional depending on if the web application has authentication or not.

The problem I have is when I choose the option “Use this template” to generate new repositories and include all branches, then clone the new repository and merge feature/auth with develop an error shows up:

fatal: refusing to merge unrelated histories

I tried running git merge feature/auth --allow-unrelated-histories

But I got a lot of conflicts and I don’t want people who use the template to have to solve conflicts.

I don’t have this problem with the original repository, only with the template generated ones.

This are the steps to reproduce the issue:

  1. navigate to the template repository.
  2. click the option “Use this template”.
  3. fill the repository name field with any name you want and check the “Include all branches” checkbox, then click the “Create repository from template” button.
  4. after the new repository is generated, clone it to your computer.
  5. Enter the repository directory and run the following commands:
$ git fetch --all
$ git checkout feature/auth
$ git checkout develop
$ git merge feature/auth

I’ve asked in StackOverflow and some other forums but got no help at all. Can somebody please help me with this?

Thank you very much in advance.