我试图在运行osx 10.8.2的mac mini上设置一个远程git服务器。 我已经设置了ssh,以便客户端可以连接到远程主机上的git帐户。 当我尝试从一个客户端执行git push origin master时,我收到以下错误:
bash:git-receive-pack:找不到命令
致命:无法从远程存储库读取。
(从我得到的另一个客户:
bash:找不到git-upload-pack:命令
致命的错误。
我确保安装了git receive pack和git upload pack,并在客户端和主机的路径中安装。
我该怎么做才能解决问题?
I am trying to set up a remote git server on a mac mini running osx 10.8.2. I have set up ssh so that the clients can connect to the git account on the remote host. When I try to execute git push origin master from one client I get the following error:
bash: git-receive-pack: command not found
fatal: Could not read from remote repository.
(From another client I get:
bash: git-upload-pack: command not found
And fatal error.
I have made sure that git receive pack and git upload pack are installed and in the path on both the client and host.
What can I do to fix or troubleshoot the problem?
最满意答案
阅读这篇文章帮助我弄清楚如何解决问题。 因为该线程假定我没有的背景知识(以及其他新手可能没有),所以我总结并尝试简化这里的答案。
Git push显然是通过“非登录”帐户工作,即没有密码的帐户。 看到这里 。 非登录git帐户的路径变量与普通登录帐户的路径不同 。 即使您登录到远程计算机,键入echo $ PATH仍将仅显示您的路径, 而不是非登录帐户的路径。 要查看非登录帐户的路径,您必须键入(从客户端):
ssh你@ remotemachine echo \ $ PATH
(反斜杠使本地机器在到达远程机器之前不会拦截和扩展$ PATH变量。)这样做会返回非登录帐户的路径。 在我的例子中,非登录帐户的默认路径不包括相关git文件的路径。 一旦我添加了git-upload&c的路径,一切正常。 通过“将其设置为.bashrc(对于Bash),. zshenv(对于Zsh),. cshrc(对于tcsh)或等效的shell,可以将正确的路径添加到远程计算机上的非登录帐户的默认路径中。 “
希望这可以帮助其他人解决这个问题。
Reading through this post helped me figure out how to solve the problem. Because the thread assumes background knowledge that I did not have (and which other novices may not have), I summarize and try to simplify the answer here.
Git push apparently works through a "non-login" account, i.e., one which does not have a password. See here. The path variable for the non-login git account is different from the path for an ordinary login account. Even if you login into the remote machine, typing echo $PATH will still only show your path, not the path of the non-login account. To see what the path of the non-login account is you have to type (from the client):
ssh you@remotemachine echo \$PATH
(The backslash keeps the local machine from intercepting and expanding the $PATH variable before it gets to the remote machine.) Doing so returns the path for non-login accounts. In my case, the default path for non-login accounts did not include the path to the relevant git files. Once I added the path to git-upload &c, everything worked fine. The correct path can be added to the default path for non-login accounts on the remote machine by "setting it in .bashrc (for Bash), .zshenv (for Zsh), .cshrc (for tcsh) or equivalent for your shell."
Hope this helps anyone else with this problem.
更多推荐
发布评论