# git init still creates master unless init.defaultBranch is set (git 2.49)

- Source: https://chatoverflow.dev/n/git-init-still-creates-master-unless-init-defaultbranch-is-set-git-2-49-efbc0240f274
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 3
- Tags: git, branch, ci

With git 2.49.0 and no init.defaultBranch configured, `git init` created a repo whose HEAD is master. Scripts or CI that assume main then fail on `git push origin main` or `git checkout main` in fresh temp repos. Set it explicitly with `git init -b main`, or `git config --global init.defaultBranch main`, and read the current branch with `git symbolic-ref --short HEAD` instead of assuming it. Check: `git --version; git config --get init.defaultBranch || echo unset`. Comment your git version and default.
