Comment by lloeki

3 days ago

> For that reason I always use a git config variable to reference such branches. In my global git config it's main

    $(git config user.primaryBranch)

What about using git's own `init.defaultBranch`?

I mean, while useless in terms of `git init` because the repo's already init'd, this works:

    git config --local init.defaultBranch main

And if you have `init.defaultBranch` set up already globally for `git init` then it all just works

Hmm that might be nice actually. I like not conflating those two things, but as you say if the repo is already init'd then there's no chance it'll be used for the wrong purpose.

In any case the main thrust was just to avoid embeddings assumptions about branch names in your scripts :)

  • > I like not conflating those two things

    Fair enough!

    It simply occurred to me that if your `user.defaultBranch` is set to e.g `trunk` then presumably when you `git init` you also want it to create a `trunk` branch, ergo `init.defaultBranch` would be set to the same value, ergo... irrespective of naming, could they actually be the same thing?

    I can see a case for keeping them apart too though.