r-lib / gert

Simple git client for R
https://docs.ropensci.org/gert/
Other
148 stars 32 forks source link

Change default branch on `git_init()` to main, or at least an argument to set default branch #100

Closed luciorq closed 4 years ago

luciorq commented 4 years ago

Hello,

Currently, the is no way to perform, at least with a single command, the equivalent of:

git init -b main

This is already the recommended way by GitHub to start a repo that is supposed to be forwarded to GitHub.

There is any plan to change the default branch initiated to main or at least give support to change the default on repo start?

jennybc commented 4 years ago

This has to come from the tools that actually implement Git operations, which usethis does not.

So that means it has to come from the gert R package, which the dev version of usethis uses for Git work.

And gert is a wrapper around the libgit2 library. libgit2 has recently acquired the ability to honour the newly introduced core.initDefault config value, where you should express your desire for a specific default branch in new repos, such as main. libgit2 is following developments in command line Git.

The dev version of usethis, which will be released as v2.0.0 in the next month or so, already fully supports whatever the repo's default branch is, i.e. master is no longer hard-wired anywhere.

Basically, all the relevant tools have implemented these changes at their bleeding edge and it will take months for them to get released and roll out. In the interim, you may have to do a bit more manual work if you want to use main, but this will gradually become more automatic.