• Zagorath@aussie.zone
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    2 days ago

    I usually create new repos through GitHub or another central repo’s system, where it defaults to calling the main branch main. But I did recently create a new repo with my local Git’s git init, and had to deal with a master branch on a completely new repo for the first time in a while. It was actually kinda a weird experience.

    • NuXCOM_90Percent@lemmy.zip
      link
      fedilink
      arrow-up
      24
      ·
      edit-2
      2 days ago
      git checkout -b main
      git branch -D master
      git config --global init.defaultBranch main
      

      You don’t have to deal with shit if you don’t want to.

    • dohpaz42@lemmy.world
      link
      fedilink
      English
      arrow-up
      8
      ·
      2 days ago

      If you haven’t already found it, you need to change your global git config (~/.gitconfig):

      git config --global init.defaultBranch main

      (or whatever you want to call it; e.g. daddy would work too)

      For any existing repositories you want to run the following command in the existing repository root (./.git/config):

      git config set init.defaultBranch main

    • pageflight@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 days ago

      Yeah, current company has their internal git server default to master and it was a little odd first time I created a new repo. Luckily all the CI templates can recognize either name so I just switched it.