Saturday, October 20, 2012

git-upload-pack: command not found

Recently we planned to use git version control system. So I tried to setup the git server in the server machine, and everything went  well from the server side. While making local copy in the the local machine we got the below error.

$ git clone ssh://remotehost:/git-path/git/root.git
Cloning into root...
Password:
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly

The reason for this is, it is not finding the path for the git-upload-pack. you need to specify the path manually. For that just use -u option for the git clone command and specify the path of git-upload-pack path in the server.

$ git clone -u /usr/local/git/bin/git-upload-pack ssh://remotehost:/git-path/git/root.git
Cloning into 'root'...
Password:
remote: Counting objects: 408, done.
remote: Compressing objects: 100% (330/330), done.
remote: Total 408 (delta 90), reused 379 (delta 69)
Receiving objects: 100% (408/408), 27.00 MiB | 47.22 MiB/s, done.
Resolving deltas: 100% (90/90), done.

To get the path of the git-upload-pack in the server, login to the server and run which git-upload-pack command as shown below.

$ which git-upload-pack
/usr/local/git/bin/git-upload-pack

when you do git pull or git push , you may get this error.

$ git pull
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly

$git push
bash: git-receive-pack: command not found
fatal: The remote end hung up unexpectedly

To solve that problem, you can either run the below commands or  modify the config file in .git directory.

$ git config remote.origin.uploadpack /usr/local/git/bin/git-upload-pack

$ git config remote.origin.receivepack /usr/local/git/bin/git-receive-pack


or you can edit the .git/config file and add the content in the below form.

[remote "origin"]

        fetch = +refs/heads/*:refs/remotes/origin/*
        url = remote_host:/path/git/root.git
        uploadpack = /usr/local/git/bin/git-upload-pack
        receivepack = /usr/local/git/bin/git-receive-pack

Then you can able to clone the git repository, you can able to pull/push the code from/to the remote server. 


Popular Posts