Clone results in "remote HEAD refers to nonexistent ref"
Running the following command:
$ git clone git@ConnectorHost:gD1/repo8
results in:
Cloning into 'repo8'... remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done. Checking connectivity... done. warning: remote HEAD refers to nonexistent ref, unable to checkout.
To resolve this issue, do one of the following:
- Edit the repo spec to specify
refs/heads/main
as the default branch to clone from. This is required for any repo not using therefs/heads/master
default branch. For details, see Specify a default branch. -
Run the following special command to set the default branch to
refs/heads/main
:$ git clone git@ConnectorHost:@defaultbranch:gD1/repo8=refs/heads/main
This results in the following output:
git clone git@ConnectorHost:@defaultbranch:gD1/repo8=refs/heads/main Cloning into 'repo8=refs/heads/main'... repo='gD1/repo8', old DefaultBranch='', new DefaultBranch='refs/heads/main' fatal: Could not read from remote repository.
NoteThe special command sets the default branch even if Git cannot parse it and the commands terminates with:
Fatal: Could not read from remote repository.
You can also run
@defaultbranch:gD1/repo8
to show the default branch and@defaultbranch:gD1/repo8=
to clear the default branch.