Fix git-upload-pack and git-receive-pack errors on shared hosting


When pulling from a remote git repository located on shared hosting you will get the “git-upload-pack: command not found” error. A similar error occurs with the git-receive-pack when doing a push as well. This occurs when git is installed locally (in your home directory), and not system wide because git cannot locate these binaries.

Normally this can be fixed by setting the $PATH environment variable to include the correct path to these binaries on the remote server. Unfortunately it will not work in this case as .bashrc is not sourced since the command is invoked in non-interactive mode via ssh.

There are 2 solutions to this problem.

The first solution is to explicitly include the path to the binaries when pushing or pulling from your local repository.

$ git pull --upload-pack /path/to/git/git-upload-pack$ git push --receive-pack /path/to/git/git-receive-pack

The second solution involves adding the path to your git-upload-path and git-recieve-path in your local .git/config file under [remote “origin”]. This is the easiest method as you only have to make this change once.

[remote "origin"] url = <repo address>
fetch = +refs/heads/*:refs/remotes/origin/*
uploadpack = <path to git-upload-pack>
receivepack = <path to git-receive-pack>

  • Julie

    I do have the problem you are talking about and your answer seems interesting, but I don’t succeed in specifying the (as my path contain a space, it seems)
    More exactly when I write:

    git push --receive-pack /cygdrive/c/Program Files/Git/cmd
    (I have installed cygwin on my remote repository)

    I have the error:
    bash: C:/Program: No such file or directory

    I have the same error response if I write just:
    git push --receive-pack /cmd , without “Program Files” in my path.

    Could you help me?

    • yinn

      Hello Julie,
      you have to escape the whitespace with a backslash like this
      git push --receive-pack /cygdrive/c/Program\ Files/Git/cmd
      i hope i’ve helped

      best regards

  • someone

    I don’t know

  • dsweetman

    Excellent! This solved my problem pretty handily on godaddy shared hosting, the bad news is now I can put off switching to new hosting for a while.