I getting this error when ever I do git clone
Error :-
fatal: invalid branch name: init.defaultBranch =
Tried to reinstall git (latest)
Still same error
OS :- Windows
I getting this error when ever I do git clone
Error :-
fatal: invalid branch name: init.defaultBranch =
Tried to reinstall git (latest)
Still same error
OS :- Windows
It would appear that you have experimented with the new (2.28) init.defaultBranch configuration value.
Assign it a proper value:
git config --global init.defaultBranch main
With Git 2.30 (Q1 2021), this should be clearer, as the users are trained to prepare for future change of init.defaultBranch configuration variable.
See commit 675704c, commit cc0f13c, commit cfaff3a, commit 1296cbe (11 Dec 2020) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano -- gitster -- in commit 772bdcd, 18 Dec 2020)
init: provide useful advice aboutinit.defaultBranchSigned-off-by: Johannes Schindelin
To give ample warning for users wishing to override Git's the fall-back for an unconfigured
init.defaultBranch(in case we decide to change it in a future Git version), let's introduce some advice that is shown upongit init(man) when that value is not set.Note: two test cases in Git's test suite want to verify that the
stderroutput of[git init](https://github.com/git/git/blob/675704c74dd4476f455bfa91e72eb9e163317c10/Documentation/git-init.txt)<sup>([man](https://git-scm.com/docs/git-init))</sup>is empty.
It is now necessary to suppress the advice, we now do that via theinit.defaultBranchsetting. While not strictly necessary, we also set this tofalseintest_create_repo().
The advice now is:
Using '%s' as the name for the initial branch.
This default branch name is subject to change.
To configure the initial branch name to use in all of your new repositories, which will suppress this warning, call:git config --global init.defaultBranch <name>Names commonly chosen instead of '
master' are 'main', 'trunk' and 'development'.
The just-created branch can be renamed via this command:git branch -m <name>
And:
init: documentinit.defaultBranchbetterInitial-patch-by: Junio C Hamano
Signed-off-by: Johannes Schindelin
Our documentation does not mention any future plan to change 'master' to other value. It is a good idea to document this, though.
git init now includes in its man page:
An initial branch without any commits will be created (see the
--initial-branchoption below for its name).
git init now includes in its man page:
--initial-branchUse the specified name for the initial branch in the newly created repository.
If not specified, fall back to the default name (currentlymaster, but this is subject to change in the future; the name can be customized via theinit.defaultBranchconfiguration variable).
I was having same error during react App Deployment on Git-hub pages
tried code :
git config ---global init.defaultBranch master
You can set it to a value as mentioned in @CodeCaster's comment.
But It would make life easier is you just unset that value so that the default configured one from the remote will be chosen.
You can either use the follwoing command:
git config --unset --global init.defaultBranch
Or remove the corresponding config line from ~/.gitconfig file.