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.
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.
First, confirm the repository isn't genuinely empty:
# 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 commitsIf 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.
The default branch might be empty while content exists on other branches:
# 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/mainSome repositories have content on main while the default is set to master (or vice versa). Others might use branch names like develop or trunk.
Incorrect URLs or authentication issues can result in cloning an empty repository:
# 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 [email protected]:user/repo.gitTry switching between HTTPS and SSH:
# If using HTTPS, try SSH
git remote set-url origin [email protected]:user/repo.git
git fetch
# If using SSH, try HTTPS
git remote set-url origin https://github.com/user/repo.git
git fetchSome server configurations (especially self-hosted GitLab) may have issues with one protocol but not the other.
If you're setting up a new repository and intentionally cloned an empty one, add initial content:
# 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 mainNote: Make sure to push to the branch that matches your hosting platform's default (usually main for GitHub, though some older repos use master).
If you created a repository via API or CLI and immediately cloned, there might be a sync delay:
# 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 --allThis is particularly common with:
- CI/CD pipelines that create and clone repositories
- Automated scripts using APIs
- Large organizations with distributed Git servers
You might have partial access - able to clone but not see content:
# Test SSH authentication
ssh -T [email protected]
# 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.
If the above steps reveal the repository should have content, try a fresh clone:
# 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.gitThe -v flag shows detailed progress and can help identify where issues occur.
### 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:
- uses: actions/checkout@v4
with:
# Ensure you're checking out the right ref
ref: main
# Fetch all branches if needed
fetch-depth: 0GitLab CI:
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:
# 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:
# 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/reposThe 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:
# 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 [email protected]:user/repo.gitwarning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server