Problem
A clone finishes without an error, but the project directory contains only .git, plus .idea once the IDE opens it. No source files.
Running the same clone from the command line shows the reason:
warning: remote HEAD refers to nonexistent ref, unable to checkout
It is a warning, not an error, so git clone exits 0 and the IDE reports success.
Cause
The remote repository's HEAD names a branch that does not exist there, so git has nothing to check out. All objects and refs are fetched; only the checkout is skipped.
The usual trigger is a default branch renamed from master to main without updating the hosting service's default-branch setting.
Resolution
Confirm the cause inside the cloned directory:
git ls-remote origin
The branch named by HEAD is missing from the listed refs. Empty output means something else: the remote has no commits at all.
Check out a listed branch. All objects are already local, so re-cloning is unnecessary: For example:
git checkout main
Fix it permanently on the hosting side by setting the repository's default branch to one that exists. For a self-hosted bare repository: For example:
git symbolic-ref HEAD refs/heads/main
Until that is done, clone with an explicit branch: git clone --branch main <repository-url>. The Clone Repository dialog has no branch field, so this route needs the command line.
Comments
0 comments
Please sign in to leave a comment.