How to fix fatal: remote error: repository not exported in Git

GitINTERMEDIATEMEDIUMUpdated Dec 6, 2025ยท 137 views

This error occurs when git-daemon refuses to serve a repository because it lacks the git-daemon-export-ok file or the --export-all flag is not set. The daemon requires explicit permission to export repositories over the git:// protocol.

Quick fix

Fixes fatal: remote error: repository not exported

# Navigate to the repository
cd /path/to/repo.git

# Create the export marker file
touch git-daemon-export-ok
  1. Create the git-daemon-export-ok file
  2. Verify file permissions
  3. Check git-daemon configuration
  4. Alternative: Use --export-all flag
git โ€” error
# Navigate to the repository
cd /path/to/repo.git
# Create the export marker file
touch git-daemon-export-ok
fatal: remote error: repository not exported

What this error means

The "repository not exported" error is a security feature of git-daemon that prevents unauthorized access to Git repositories over the git:// protocol. Git-daemon requires repositories to explicitly opt-in to being served publicly by checking for the presence of a special marker file called git-daemon-export-ok in the repository root. When you attempt to clone or fetch from a repository via git-daemon (using git:// URLs), the daemon verifies this file exists before allowing access. If the file is missing and the daemon wasn't started with --export-all, it will reject the request with this error message. This mechanism ensures that only repositories intentionally marked as public are accessible through the git:// protocol, preventing accidental exposure of private repositories on servers running git-daemon.

Typical symptoms

  • Cannot clone repository using git:// protocol
  • Clone or fetch commands fail with "fatal: remote error: repository not exported"
  • Error message "The remote end hung up unexpectedly" follows the export error
  • Repository is accessible via other protocols (SSH, HTTPS) but not git://
  • Error occurs immediately without any authentication prompt

Common causes

  1. The git-daemon-export-ok file is missing from the repository
  2. The git-daemon-export-ok file is in the wrong location (parent directory instead of .git directory)
  3. Git-daemon was started without the --export-all flag
  4. File permissions prevent git-daemon from reading the git-daemon-export-ok file
  5. Repository path is not in the git-daemon whitelist (trailing slash or path issues)
  6. Repository directory is not accessible by the user running git-daemon

How to fix "fatal: remote error: repository not exported"

1Create the git-daemon-export-ok file

For a bare repository, create an empty marker file in the repository root:

bash
# Navigate to the repository
cd /path/to/repo.git

# Create the export marker file
touch git-daemon-export-ok

For a non-bare repository, place it inside the .git directory:

bash
cd /path/to/repo/.git
touch git-daemon-export-ok

Important: Do not commit this file to the repository. It should exist only on the server filesystem.

2Verify file permissions

Ensure the git-daemon-export-ok file is readable by the user running git-daemon:

bash
# Check current permissions
ls -la /path/to/repo.git/git-daemon-export-ok

# Make it readable if needed
chmod 644 /path/to/repo.git/git-daemon-export-ok

If git-daemon runs as a specific user (e.g., git-ro), verify that user can read the file:

bash
sudo -u git-ro cat /path/to/repo.git/git-daemon-export-ok
3Check git-daemon configuration

Verify your git-daemon is configured correctly. Check the systemd service or init script:

bash
# View the service configuration
systemctl cat git-daemon

# Or check the running process
ps aux | grep git-daemon

Common configuration issues:
- Trailing slash: Remove trailing slashes from directory paths in the daemon command
- Base path: Ensure --base-path is set correctly
- Whitelist: Verify repository paths are included

4Alternative: Use --export-all flag

If you want to export all repositories without requiring the marker file, start git-daemon with --export-all:

bash
git daemon --base-path=/srv/git --export-all --reuseaddr --verbose

Warning: This exports ALL repositories in the base path. Only use this if you're certain all repositories should be publicly accessible.

To update a systemd service:

bash
# Edit the service file
sudo systemctl edit --full git-daemon

# Add --export-all to the ExecStart line
# Then reload and restart
sudo systemctl daemon-reload
sudo systemctl restart git-daemon
5Test repository access

After making changes, test that the repository is now accessible:

bash
# Try cloning from the git:// URL
git clone git://server-hostname/path/to/repo.git

# Check git-daemon logs for issues
journalctl -u git-daemon -n 50

If the clone succeeds, the repository is now properly exported.

Advanced notes

Git Protocol Limitations:
The git:// protocol is read-only by default and provides no authentication or encryption. For push access, you need to explicitly enable receive-pack by adding [daemon] receivepack = true to the repository's config file or using --enable=receive-pack when starting git-daemon. However, this is rarely recommended due to security concerns.

Security Considerations:
The git-daemon-export-ok mechanism is intentionally restrictive to prevent accidental exposure of private repositories. Before exporting repositories, ensure they contain no sensitive data. For internal networks, consider using SSH or HTTPS protocols instead, which provide authentication and encryption.

Informative Errors:
Git-daemon has an --informative-errors flag that provides more detailed error messages to clients, differentiating between "repository not found" and "repository not exported". However, this may leak information about the existence of unexported repositories. The default is --no-informative-errors for security.

Modern Alternatives:
The git:// protocol is less commonly used today. Most Git hosting is done over HTTPS (with authentication) or SSH. Consider whether git-daemon is necessary for your use case, or if HTTP-based serving with git-http-backend would be more appropriate.

Frequently asked questions

What does "fatal: remote error: repository not exported" mean?
The "repository not exported" error is a security feature of git-daemon that prevents unauthorized access to Git repositories over the git:// protocol. Git-daemon requires repositories to explicitly opt-in to being served publicly by checking for the presence of a special marker file called git-daemon-export-ok in the repository root. When you attempt to clone or fetch from a repository via git-daemon (using git:// URLs), the daemon verifies this file exists before allowing access.
How do I fix "fatal: remote error: repository not exported"?
This error occurs when git-daemon refuses to serve a repository because it lacks the git-daemon-export-ok file or the --export-all flag is not set. The daemon requires explicit permission to export repositories over the git:// protocol.
What causes "fatal: remote error: repository not exported"?
The git-daemon-export-ok file is missing from the repository The git-daemon-export-ok file is in the wrong location (parent directory instead of .git directory) Git-daemon was started without the --export-all flag
Is the "fatal: remote error: repository not exported" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading