How to fix fatal: Could not read from remote repository. 'git-upload-pack' command not found in Git

GitINTERMEDIATEMEDIUMUpdated Dec 7, 2025ยท 125 views

This error occurs when Git cannot find the git-upload-pack executable on the remote server during clone, fetch, or pull operations. It typically indicates a PATH configuration issue with non-interactive SSH sessions.

Quick fix

Fixes fatal: Could not read from remote repository. 'git-upload-pack' command not found

ssh user@remote-server which git-upload-pack
  1. Verify Git installation on remote server
  2. Use --upload-pack flag for immediate fix
  3. Configure remote uploadpack path permanently
  4. Fix PATH in remote server .bashrc
git โ€” error
ssh user@remote-server which git-upload-pack
fatal: Could not read from remote repository. 'git-upload-pack' command not found

What this error means

The git-upload-pack error occurs when your local Git client attempts to communicate with a remote repository over SSH, but the remote server cannot locate the git-upload-pack executable. This command is a critical component of Git's network protocol - it runs on the server side during fetch and clone operations to send repository data to the client. The root cause is almost always a PATH environment variable issue. When you connect to a remote server via SSH to run Git commands, the SSH daemon launches a non-interactive shell that has a different environment than a normal login shell. If Git is installed in a non-standard location (like /usr/local/git/bin or /opt/git/bin), the non-interactive shell's PATH may not include that directory, causing the git-upload-pack command to be unavailable. This issue is particularly common on macOS servers where Git is installed via Homebrew or custom installations, and on Linux servers where Git is compiled from source or installed in non-standard locations. It can affect any Git operation that reads from a remote repository, including git clone, git fetch, git pull, and git submodule update.

Typical symptoms

  • git clone fails with 'git-upload-pack: command not found' error
  • git fetch or git pull operations fail on remote repositories
  • Error message includes 'Could not read from remote repository'
  • SSH login to the server works fine, but Git operations fail
  • Git commands work when logged into the server directly but fail over SSH
  • IDE or GUI Git tools report connection failures to remote repositories

Common causes

  1. Git is installed in a location not included in the non-interactive SSH shell PATH (most common)
  2. Git is not installed on the remote server at all
  3. The SSH daemon configuration restricts environment variables
  4. User's .bashrc or .bash_profile does not export PATH for non-interactive shells
  5. Different PATH settings between interactive login shells and non-interactive SSH sessions
  6. Git binaries are installed but the user account lacks execute permissions

How to fix "fatal: Could not read from remote repository. 'git-upload-pack' command not found"

1Verify Git installation on remote server

First, confirm that Git is installed on the remote server and locate the git-upload-pack executable:

bash
ssh user@remote-server which git-upload-pack

If this returns a path (like /usr/bin/git-upload-pack or /usr/local/git/bin/git-upload-pack), Git is installed. If it returns nothing or "command not found", Git needs to be installed on the remote server.

You can also check the PATH seen by non-interactive SSH sessions:

bash
ssh user@remote-server echo \/home/jonas/.local/bin:/home/jonas/.vscode-server/bin/bf9252a2fb45be6893dd8870c0bf37e2e1766d61/bin/remote-cli:/home/jonas/.local/bin:/home/jonas/.local/bin:/home/jonas/.nvm/versions/node/v24.6.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Python313/Scripts/:/mnt/c/Python313/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA app/NvDLISR:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/nodejs/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/Jonas/AppData/Local/Programs/Python/Python312/Scripts/:/mnt/c/Users/Jonas/AppData/Local/Programs/Python/Python312/:/mnt/c/Users/Jonas/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Jonas/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Jonas/AppData/Roaming/npm:/snap/bin:/home/jonas/.local/bin:/home/jonas/.local/bin:/home/jonas/.local/bin

Compare this to your interactive shell PATH to identify missing directories.

2Use --upload-pack flag for immediate fix

If you know where git-upload-pack is located on the remote server, specify it explicitly in your Git command:

bash
# For clone operations
git clone --upload-pack /usr/local/bin/git-upload-pack user@remote:repo.git

# For fetch operations
git fetch --upload-pack /usr/local/bin/git-upload-pack

This bypasses the PATH issue by telling Git exactly where to find the command.

3Configure remote uploadpack path permanently

To avoid specifying the path every time, configure it in your repository's Git config:

bash
# Configure for a specific remote (usually origin)
git config remote.origin.uploadpack /usr/local/bin/git-upload-pack
git config remote.origin.receivepack /usr/local/bin/git-receive-pack

# Verify the configuration
git config --get remote.origin.uploadpack

Now all future fetch and pull operations will use the specified path automatically.

4Fix PATH in remote server .bashrc

On the remote server, ensure that .bashrc (not just .bash_profile) exports the correct PATH for non-interactive shells:

bash
# SSH to the remote server
ssh user@remote-server

# Edit .bashrc
vi ~/.bashrc

# Add or modify PATH to include Git location
export PATH=/home/jonas/.local/bin:/home/jonas/.vscode-server/bin/bf9252a2fb45be6893dd8870c0bf37e2e1766d61/bin/remote-cli:/home/jonas/.local/bin:/home/jonas/.local/bin:/home/jonas/.nvm/versions/node/v24.6.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Python313/Scripts/:/mnt/c/Python313/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA app/NvDLISR:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/nodejs/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/Jonas/AppData/Local/Programs/Python/Python312/Scripts/:/mnt/c/Users/Jonas/AppData/Local/Programs/Python/Python312/:/mnt/c/Users/Jonas/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Jonas/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Jonas/AppData/Roaming/npm:/snap/bin:/home/jonas/.local/bin:/home/jonas/.local/bin:/home/jonas/.local/bin:/usr/local/git/bin

# Ensure .bashrc is sourced for non-interactive shells
# Add this to .bash_profile if needed:
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

Test the fix by running the diagnostic SSH command again:

bash
ssh user@remote-server which git-upload-pack
5Configure SSH environment variables (advanced)

For a system-wide fix on the remote server, you can configure SSH to preserve PATH environment variables. This requires root access.

Edit /etc/ssh/sshd_config on the remote server:

bash
sudo vi /etc/ssh/sshd_config

# Add or uncomment this line:
PermitUserEnvironment yes

Then create ~/.ssh/environment file for the user:

bash
# Create the environment file
vi ~/.ssh/environment

# Add the PATH:
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin

Restart the SSH daemon:

bash
sudo systemctl restart sshd
# or on older systems:
sudo service sshd restart

Note: Enabling PermitUserEnvironment has security implications and may not be allowed by your organization's policies.

Advanced notes

The distinction between interactive and non-interactive shells is crucial to understanding this error. When you SSH into a server with a terminal (ssh user@server), it creates a login shell that executes .bash_profile or .profile. However, when Git connects over SSH to run git-upload-pack, it creates a non-interactive shell that only sources .bashrc. On macOS, Git installations via Homebrew or official DMG typically install to /usr/local/git/bin, which is not in the default system PATH compiled into sshd for security reasons.

For Git hosting platforms like Gitolite, Gitea, or custom Git servers, the git user often has a restricted shell. In these cases, ensure the PATH is set in the git user's shell initialization files or use the --upload-pack flag approach.

If you're using Git submodules, this error can occur when the superproject and submodule use different remote server configurations. Ensure all submodules have the uploadpack path configured if needed.

Some organizations use Git protocol wrappers or proxies that may require additional configuration beyond standard PATH fixes.

Frequently asked questions

What does "fatal: Could not read from remote repository. 'git-upload-pack' comman" mean?
The git-upload-pack error occurs when your local Git client attempts to communicate with a remote repository over SSH, but the remote server cannot locate the git-upload-pack executable. This command is a critical component of Git's network protocol - it runs on the server side during fetch and clone operations to send repository data to the client. The root cause is almost always a PATH environment variable issue.
How do I fix "fatal: Could not read from remote repository. 'git-upload-pack' comman"?
This error occurs when Git cannot find the git-upload-pack executable on the remote server during clone, fetch, or pull operations. It typically indicates a PATH configuration issue with non-interactive SSH sessions.
What causes "fatal: Could not read from remote repository. 'git-upload-pack' comman"?
Git is installed in a location not included in the non-interactive SSH shell PATH (most common) Git is not installed on the remote server at all The SSH daemon configuration restricts environment variables
Is the "fatal: Could not read from remote repository. 'git-upload-pack' comman" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading