Repository: jesseduffield/lazygit (language: go)

Issue:
Ability to choose the default branch name when creating a new repo
**Is your feature request related to a problem? Please describe.**
Lazygit names the default branch `master`

**Describe the solution you'd like**
Would be nice to choose the default branch name when creating a new git repo with lazygit: the default branch name lazygit chooses right now is `master`.



Discussion / hints:
You can set a default in your git config with `init.defaultBranch`. I'm pretty sure lazygit will honour that. Does that suffice for your use case, or would you like to be able to type in a branch name? I assume most people go with master/main
Yeah, it would be nice to type the branch name when creating a repo.

Fix patch:
diff --git a/pkg/app/app.go b/pkg/app/app.go
index a5a241ac550..9a7b1ffcc00 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -173,12 +173,20 @@ func (app *App) setupRepo() (bool, error) {
 
 		shouldInitRepo := true
 		notARepository := app.UserConfig.NotARepository
+		initialBranch := ""
 		if notARepository == "prompt" {
 			// Offer to initialize a new repository in current directory.
 			fmt.Print(app.Tr.CreateRepo)
 			response, _ := bufio.NewReader(os.Stdin).ReadString('\n')
 			if strings.Trim(response, " \r\n") != "y" {
 				shouldInitRepo = false
+			} else {
+				// Ask for the initial branch name
+				fmt.Print(app.Tr.InitialBranch)
+				response, _ := bufio.NewReader(os.Stdin).ReadString('\n')
+				if trimmedResponse := strings.Trim(response, " \r\n"); len(trimmedResponse) > 0 {
+					initialBranch += "--initial-branch=" + trimmedResponse
+				}
 			}
 		} else if notARepository == "skip" {
 			shouldInitRepo = false
@@ -197,7 +205,7 @@ func (app *App) setupRepo() (bool, error) {
 			fmt.Println(app.Tr.NoRecentRepositories)
 			os.Exit(1)
 		}
-		if err := app.OSCommand.Cmd.New("git init").Run(); err != nil {
+		if err := app.OSCommand.Cmd.New("git init " + initialBranch).Run(); err != nil {
 			return false, err
 		}
 	}
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 975cc928513..4f5b4eb48d0 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -258,6 +258,7 @@ type TranslationSet struct {
 	DiscardFileChangesPrompt            string
 	DisabledForGPG                      string
 	CreateRepo                          string
+	InitialBranch                       string
 	NoRecentRepositories                string
 	AutoStashTitle                      string
 	AutoStashPrompt                     string
@@ -884,6 +885,7 @@ func EnglishTranslationSet() TranslationSet {
 		DiscardFileChangesPrompt:            "Are you sure you want to discard this commit's changes to this file? If this file was created in this commit, it will be deleted",
 		DisabledForGPG:                      "Feature not available for users using GPG",
 		CreateRepo:                          "Not in a git repository. Create a new git repository? (y/n): ",
+		InitialBranch:                       "Branch name? (leave empty for git's default): ",
 		NoRecentRepositories:                "Must open lazygit in a git repository. No valid recent repositories. Exiting.",
 		AutoStashTitle:                      "Autostash?",
 		AutoStashPrompt:                     "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)",


Test patch: