Chris Chris - 2 years ago 308
Bash Question

git-upload-pack: command not found

I've read this answer about eight-five times, but there's something I'm not understanding correctly:

git-upload-pack: command not found, how to fix this correctly

When I try to clone a repository on my server, I get the following:

bash: git-upload-pack: command not found

But when I clone by giving clone the
-u /usr/local/bin/git-upload-pack
option, all works well.

I guess this makes sense, since that's the position of the git-upload-pack on my server.

The top answer suggests my .bashrc file on server needs to be updated to reflect this, as the result of
ssh you@remotemachine echo \$PATH
does not return
. (It returns

But when I look at my .bashrc file, it contains:

export PATH=/usr/local/bin:$PATH

So now I'm confused.

What do I need to do to avoid using the
-u /usr/local/bin/git-upload-pack
option every time? Why does
ssh you@remotemachine echo \$PATH
not return
? Is this something to do with login and non-login shells?

Please help! Thanks in advance.

Answer Source

This is connected to this issue:

Ssh is not loading your environment by default when sending a command without going to interactive mode.

good solution is the one with .ssh/environment file:

in /etc/ssh/sshd_config add:

PermitUserEnvironment yes

Then just create .ssh/ directory and dump envronment to .ssh/enviroment:

cd ~/
mkdir .ssh
env > .ssh/environment

Restart SSH

/etc/init.d/sshd restart

Now when you do this from your local machine:

ssh  "which git-upload-pack"

you s'd get


and git clone s'd work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download