How to fix warning: You appear to have cloned an empty repository in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 335 views

This Git warning appears when cloning a repository that has no commits. While non-fatal, it often signals a newly created repo, wrong branch configuration, or access issues. Verify the repository has content, check the default branch, or ensure proper authentication.

Quick fix

Fixes warning: You appear to have cloned an empty repository

# Check if any remote branches exist
git branch -r

# List all references on the remote
git ls-remote origin

# If output is empty or only shows HEAD with no refs,
# the repository truly has no commits
  1. Verify the repository actually has content
  2. Check and switch to the correct branch
  3. Verify remote URL and authentication
  4. For new repositories - make an initial commit
git โ€” error
# Check if any remote branches exist
git branch -r
# List all references on the remote
git ls-remote origin
# If output is empty or only shows HEAD with no refs,
# the repository truly has no commits
warning: You appear to have cloned an empty repository

What this error means

The "You appear to have cloned an empty repository" warning is displayed by Git when you successfully clone a repository that contains no commits. This is a non-fatal warning, not an error - Git has completed the clone operation, but it's alerting you that the repository has no content to download. When Git clones a repository, it copies all branches, commits, and history from the remote. If none of these exist, Git creates an empty local repository with only the basic Git structure (the `.git` directory). This warning is Git's way of telling you that while the operation succeeded technically, you might not have gotten what you expected. This situation commonly arises in several scenarios: you've cloned a brand-new repository before any initial commits were made, you're targeting a branch that doesn't exist or is empty while content exists elsewhere, or there's a configuration or permission issue preventing Git from seeing the actual repository content. Understanding which scenario applies to your situation is key to resolving the warning.

Typical symptoms

  • Clone command completes with warning 'You appear to have cloned an empty repository'
  • Cloned directory exists but contains no files (only hidden .git folder)
  • Running 'git branch -r' shows no remote branches
  • git status shows 'On branch master' with 'No commits yet'
  • Attempting 'git pull' fails with 'couldn't find remote ref master'
  • Repository appears to have content on GitHub/GitLab web interface but local clone is empty
  • CI/CD pipeline clones empty repository despite commits existing on remote

Common causes

  1. Repository was just created and has no initial commits or files
  2. Files exist locally but were never added/committed to the repository
  3. Default branch (main/master) is empty while content exists on other branches
  4. Protocol mismatch - using HTTPS instead of SSH (or vice versa) causes silent authentication failure
  5. Server configuration issue - GitLab/GitHub HTTP misconfiguration or reverse proxy problems
  6. Timing race condition - cloning immediately after repository creation before server sync
  7. Insufficient permissions - user can access repository metadata but not actual content
  8. Repository URL is incorrect or points to a different (empty) repository

How to fix "warning: You appear to have cloned an empty repository"

1Verify the repository actually has content

First, confirm the repository isn't genuinely empty:

bash
# Check if any remote branches exist
git branch -r

# List all references on the remote
git ls-remote origin

# If output is empty or only shows HEAD with no refs,
# the repository truly has no commits

If git ls-remote shows commit hashes, the repository has content but something prevented it from being cloned. If the output is empty, the repository genuinely has no commits.

Check the repository directly on your Git hosting platform (GitHub, GitLab, Bitbucket) to see if commits and files are visible there.

2Check and switch to the correct branch

The default branch might be empty while content exists on other branches:

bash
# List all remote branches
git ls-remote --heads origin

# If you see branches listed, fetch them
git fetch --all

# Switch to a branch that has content
git checkout <branch-name>

# Or checkout a remote branch
git checkout -b main origin/main

Some repositories have content on main while the default is set to master (or vice versa). Others might use branch names like develop or trunk.

3Verify remote URL and authentication

Incorrect URLs or authentication issues can result in cloning an empty repository:

bash
# Check the configured remote URL
git remote -v

# Verify you can access the repository
# For HTTPS:
git ls-remote https://github.com/user/repo.git

# For SSH:
git ls-remote git@github.com:user/repo.git

Try switching between HTTPS and SSH:

bash
# If using HTTPS, try SSH
git remote set-url origin git@github.com:user/repo.git
git fetch

# If using SSH, try HTTPS
git remote set-url origin https://github.com/user/repo.git
git fetch

Some server configurations (especially self-hosted GitLab) may have issues with one protocol but not the other.

4For new repositories - make an initial commit

If you're setting up a new repository and intentionally cloned an empty one, add initial content:

bash
# Add a README file
echo "# My Project" > README.md

# Stage and commit
git add README.md
git commit -m "Initial commit"

# Push to remote
git push -u origin main

Note: Make sure to push to the branch that matches your hosting platform's default (usually main for GitHub, though some older repos use master).

5Wait and retry for timing issues

If you created a repository via API or CLI and immediately cloned, there might be a sync delay:

bash
# For GitHub CLI created repos, add a small delay
gh repo create my-repo --public
sleep 3  # Wait a few seconds
git clone https://github.com/user/my-repo.git

# If you already cloned, just fetch again
cd my-repo
git fetch --all

This is particularly common with:
- CI/CD pipelines that create and clone repositories
- Automated scripts using APIs
- Large organizations with distributed Git servers

6Check for permission or access issues

You might have partial access - able to clone but not see content:

bash
# Test SSH authentication
ssh -T git@github.com

# Check your credentials are working
git credential fill <<< "protocol=https
host=github.com"

Common permission scenarios:
- Repository requires specific team membership
- SSH key isn't added to your account
- Personal access token lacks necessary scopes
- SAML SSO session has expired

Re-authenticate or request proper access from the repository owner.

7Re-clone the repository

If the above steps reveal the repository should have content, try a fresh clone:

bash
# Remove the existing empty clone
cd ..
rm -rf my-repo

# Clone again with verbose output
git clone -v https://github.com/user/my-repo.git

# Or clone a specific branch
git clone -b main https://github.com/user/my-repo.git

The -v flag shows detailed progress and can help identify where issues occur.

Advanced notes

### Understanding Empty Repository States

A Git repository can be "empty" in different ways:

| State | git ls-remote output | Cause |
|-------|------------------------|-------|
| No commits | Empty or HEAD only | Repository initialized but never committed to |
| Empty default branch | Shows other branches | Content exists but not on the default branch |
| Access issue | May show nothing | Permission problem or protocol issue |

### CI/CD Considerations

In automated pipelines, empty repository warnings often indicate:

GitHub Actions:

yaml
- uses: actions/checkout@v4
  with:
    # Ensure you're checking out the right ref
    ref: main
    # Fetch all branches if needed
    fetch-depth: 0

GitLab CI:

yaml
variables:
  # Ensure full clone
  GIT_STRATEGY: clone
  GIT_DEPTH: 0

# Or specify the branch explicitly
script:
  - git checkout $CI_DEFAULT_BRANCH

### Self-Hosted Git Server Issues

For GitLab CE/EE and other self-hosted solutions:

1. Reverse proxy configuration - Ensure nginx/Apache properly forwards Git HTTP requests
2. Repository storage - Check Gitaly (GitLab) or file permissions on repository storage
3. HTTP vs SSH - Some configurations only properly support one protocol
4. Hooks - Pre-receive hooks might reject certain operations silently

Check server logs for more details:

bash
# GitLab
sudo gitlab-ctl tail gitaly
sudo gitlab-ctl tail gitlab-workhorse

# Generic Git server
tail -f /var/log/git/git-daemon.log

### Preventing Empty Repository Clones

When creating repositories programmatically:

bash
# Create with initial content using GitHub CLI
gh repo create my-repo --public --clone --add-readme

# Create with initial commit via API (GitHub)
curl -X POST -H "Authorization: token $TOKEN" \
  -d '{"name":"my-repo","auto_init":true}' \
  https://api.github.com/user/repos

The auto_init option or --add-readme flag ensures the repository has at least one commit immediately.

### Troubleshooting Protocol Issues

Different protocols have different authentication mechanisms:

| Protocol | Authentication | Common Issues |
|----------|---------------|---------------|
| HTTPS | Username/password, PAT, credential helper | 2FA blocking, token scope issues |
| SSH | SSH keys | Key not added, wrong key used, agent not running |
| Git | Anonymous | Usually read-only, often disabled |

Test each protocol:

bash
# Test HTTPS
GIT_CURL_VERBOSE=1 git ls-remote https://github.com/user/repo.git

# Test SSH
GIT_SSH_COMMAND="ssh -v" git ls-remote git@github.com:user/repo.git

Frequently asked questions

What does "warning: You appear to have cloned an empty repository" mean?
The "You appear to have cloned an empty repository" warning is displayed by Git when you successfully clone a repository that contains no commits. This is a non-fatal warning, not an error - Git has completed the clone operation, but it's alerting you that the repository has no content to download. When Git clones a repository, it copies all branches, commits, and history from the remote.
How do I fix "warning: You appear to have cloned an empty repository"?
This Git warning appears when cloning a repository that has no commits. While non-fatal, it often signals a newly created repo, wrong branch configuration, or access issues. Verify the repository has content, check the default branch, or ensure proper authentication.
What causes "warning: You appear to have cloned an empty repository"?
Repository was just created and has no initial commits or files Files exist locally but were never added/committed to the repository Default branch (main/master) is empty while content exists on other branches
Is the "warning: You appear to have cloned an empty repository" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading