bash git-upload-pack:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11128464/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git-upload-pack: command not found
提问by Chris
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
git-upload-pack:找不到命令,如何正确解决此问题
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.
但是当我通过给 clone-u /usr/local/bin/git-upload-pack
选项进行克隆时,一切正常。
I guess this makes sense, since that's the position of the git-upload-pack on my server.
我想这是有道理的,因为这是我服务器上 git-upload-pack 的位置。
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 /usr/local/bin
. (It returns /usr/bin:/bin:/usr/sbin:/sbin
).
最佳答案表明我的服务器上的 .bashrc 文件需要更新以反映这一点,因为结果ssh you@remotemachine echo \$PATH
不返回/usr/local/bin
. (它返回/usr/bin:/bin:/usr/sbin:/sbin
)。
But when I look at my .bashrc file, it contains:
但是当我查看我的 .bashrc 文件时,它包含:
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 /usr/local/bin
? Is this something to do with login and non-login shells?
我需要怎么做才能避免-u /usr/local/bin/git-upload-pack
每次都使用该选项?为什么不ssh you@remotemachine echo \$PATH
回/usr/local/bin
?这与登录和非登录shell有关吗?
Please help! Thanks in advance.
请帮忙!提前致谢。
回答by madsheep
This is connected to this issue:
这与这个问题有关:
https://serverfault.com/questions/130834/svnssh-getting-bash-to-load-my-path-over-ssh
https://serverfault.com/questions/130834/svnssh-getting-bash-to-load-my-path-over-ssh
Ssh is not loading your environment by default when sending a command without going to interactive mode.
在不进入交互模式的情况下发送命令时,默认情况下 ssh 不会加载您的环境。
good solution is the one with .ssh/environment file:
好的解决方案是带有 .ssh/environment 文件的解决方案:
in /etc/ssh/sshd_config add:
在 /etc/ssh/sshd_config 添加:
PermitUserEnvironment yes
Then just create .ssh/ directory and dump envronment to .ssh/enviroment:
然后只需创建 .ssh/ 目录并将环境转储到 .ssh/enviroment:
cd ~/
mkdir .ssh
env > .ssh/environment
Restart SSH
重启 SSH
/etc/init.d/sshd restart
Now when you do this from your local machine:
现在,当您从本地计算机执行此操作时:
ssh [email protected] "which git-upload-pack"
you s'd get
你会得到
/usr/local/bin/git-upload-pack
and git clone s'd work.
和 git clone s'd 工作。
回答by Nathan Kleyn
Yes, it is to do with login and non-login shells. The .bashrc
file only gets loaded in non-login shells. You can use .bash_profile
for login shells. Just add the same modification to your PATH
in the .bash_profile
file and you should be good.
是的,这与登录和非登录外壳有关。该.bashrc
文件仅在非登录 shell 中加载。您可以.bash_profile
用于登录 shell。只需PATH
在.bash_profile
文件中添加相同的修改,你应该会很好。
export PATH=/usr/local/bin:$PATH
You may find this is an interesting article on the difference between .bashrc and .bash_profile, and login and non-login shells.
您可能会发现这是一篇关于 .bashrc 和 .bash_profile 以及登录和非登录 shell 之间区别的有趣文章。
回答by Hugh Perkins
I solved this issue in my case by logging into the remote machine, a Ubuntu box, and doing sudo apt-get install git
. Not sure if this is overkill or not, but solved the problem for me instantly.
在我的案例中,我通过登录远程机器、Ubuntu 机器并执行sudo apt-get install git
. 不确定这是否矫枉过正,但立即为我解决了问题。
回答by drugan
My solution for this problem
我对这个问题的解决方案
Check path for the git-upload-pack on your remote machine:
ssh yourname@IP-addressORdomain 'which git-upload-pack'
检查远程机器上 git-upload-pack 的路径:
ssh yourname@IP-addressORdomain 'which git-upload-pack'
If it gives a path - copy it (without git-upload-pack
and trailing slash. Examples: /usr/bin
, /home/yourname/bin
, /whatever/gituploadpack/path
, etc.).
如果给出了一个路径-复制(不git-upload-pack
与斜线的例子:/usr/bin
,/home/yourname/bin
,/whatever/gituploadpack/path
等)。
Check your PATH on the remote machine during login shell:
ssh yourname@IP-addressORdomain 'echo $PATH'
在登录 shell 期间检查远程计算机上的 PATH:
ssh yourname@IP-addressORdomain 'echo $PATH'
There is no such a path (/whatever/gituploadpack/path
), is not it? Good!
没有这样的路径(/whatever/gituploadpack/path
),不是吗?好的!
Login to your remote machine:
ssh yourname@IP-addressORdomain
Open .bashrc_profile:
nano /home/yourname/.bashrc_profile
Find these lines if any:
if [ -f ~/.bashrc ]; then ~/.bashrc fi
登录到您的远程机器:
ssh yourname@IP-addressORdomain
打开 .bashrc_profile:
nano /home/yourname/.bashrc_profile
找到这些行(如果有):
if [ -f ~/.bashrc ]; then ~/.bashrc fi
...and change them for:
...并将它们更改为:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Open .bashrc:
nano /home/yourname/.bashrc
Add these 4 lines:
if [ -d "/whatever/gituploadpack/path" ] ; then PATH="$PATH:/whatever/gituploadpack/path" fi export PATH
Exit the remote machine:
exit
Check your PATH on the remote machine during login shell:
ssh yourname@IP-addressORdomain 'echo $PATH'
打开.bashrc:
nano /home/yourname/.bashrc
添加以下 4 行:
if [ -d "/whatever/gituploadpack/path" ] ; then PATH="$PATH:/whatever/gituploadpack/path" fi export PATH
退出远程机器:
exit
在登录 shell 期间检查远程计算机上的 PATH:
ssh yourname@IP-addressORdomain 'echo $PATH'
Do you see /whatever/gituploadpack/path
? Congrats!
你看到了/whatever/gituploadpack/path
吗?恭喜!
Note now you've solved not only git-upload-pack
problem but also git-receive-pack
and other executables on your /whatever/gituploadpack/path
!
注意现在你已经解决了,不仅git-upload-pack
问题,而且还git-receive-pack
和你的其他可执行文件/whatever/gituploadpack/path
!
回答by ssinganamalla
I was getting the following errors:
git-credential-osxkeychain died of signal 11
When I was doing git pull, I would get
fatal: https://github.com/.../../info/refs?service=git-upload-packnot found: did you run git update-server-info on the server?
我收到以下错误:
git-credential-osxkeychain died of signal 11
当我执行 git pull 时,我会得到
fatal: https://github.com/.../../info/refs?service=git-upload-packnot found: did you run git update-server-info on the server?
I am guessing it had to do with my previous invalid github credentials in the keychain.
我猜这与我以前在钥匙串中无效的 github 凭据有关。
- Opened keychain access tool using Command space
- searched for github in the keychain access tool
- removed all the entries related to github (since I no longer needed it)
- followed the setup git password caching section again setup git
- it worked
- 使用命令空间打开钥匙串访问工具
- 在钥匙串访问工具中搜索github
- 删除了所有与 github 相关的条目(因为我不再需要它)
- 再次遵循设置 git 密码缓存部分设置 git
- 有效
Incase any of the above answers does not help.
如果上述任何答案都无济于事。