cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Default git branch name is master not main on MacOS

Open songyang-dev opened this issue 1 year ago • 3 comments

Problem

On MacOS Sequoia 15.0.0, cargo init will create a project with git initialized but the default branch name is "master" instead of "main".

Steps

  1. Install the latest Rust toolchain on MacOS Sequoia 15
  2. cargo init an empty project
  3. Check the default branch name with git status.

Possible Solution(s)

Manually modify the name of the branch.

Notes

No response

Version

cargo 1.81.0 (2dbb1af80 2024-08-20) release: 1.81.0 commit-hash: 2dbb1af80a2914475ba76827a312e29cedfa6b2f commit-date: 2024-08-20 host: aarch64-apple-darwin libgit2: 1.8.1 (sys:0.19.0 vendored) libcurl: 8.7.1 (sys:0.4.73+curl-8.8.0 system ssl:(SecureTransport) LibreSSL/3.3.6) ssl: OpenSSL 1.1.1w 11 Sep 2023 os: Mac OS 15.0.0 [64-bit]

songyang-dev avatar Oct 07 '24 00:10 songyang-dev

Could you try git init and see which branch name it creates? You might also like to check in your fit config files the init.defaultBranch value.

weihanglo avatar Oct 07 '24 01:10 weihanglo

This seems like an upstream issue: https://github.com/libgit2/libgit2/issues/6883.

It might be either you don't have Apple Command-line Tools installed, or they removed the default git configuration in Sequoia. Either way, this seems to be out of control of Cargo. Cargo generally respects what libgit2 does to configuration.

weihanglo avatar Oct 07 '24 14:10 weihanglo

Could you try git init and see which branch name it creates? You might also like to check in your fit config files the init.defaultBranch value.

git init creates a main branch not master.

-> % git config --get init.defaultbranch
main

As for the libgit issue, I have a similar output.

-> % git config --show-origin --show-scope --list
unknown file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig    credential.helper=osxkeychain
unknown file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig    init.defaultbranch=main
global  file:/Users/songyang/.gitconfig user.name=Song Yang
...

songyang-dev avatar Oct 08 '24 00:10 songyang-dev