GIT:" git-upload-pack:command not found"同时推送到远程服务器 [英] GIT : "git-upload-pack: command not found" while pushing to remote server

查看:345
本文介绍了GIT:" git-upload-pack:command not found"同时推送到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




  • 在共享的unix托管中,我使用GIT尝试将代码推送到远程服务器。 m不允许拥有自己的环境变量(对SSH帐户阻止)并且不支持sudo访问。

  • 设法将git成功安装到我的/ home /

  • 尝试将代码推送到服务器返回:bash:git-upload-pack:找不到命令
  • $ PATH变量已设置 - 因为git安装在我的/ home /
  • li>
  • 为了让事情顺利进行,我不得不使用以下克隆命令:



    git clone -u / home / bin / git-upload-pack user@server.com:mygitfolder


  • 本地机器/远程服务器上的相同版本的git(1.7.0.4)




因此,从我可以收集的内容来看,我基本上需要:


  • 找到一种方法,当我每次推送到服务器

  • 时,或者在推送时指定我的git-receive-pack的路径到服务器


我明白我可以创建一个在我推送时生效的钩子,但没有设法找到它的实现方式。 / p>

(我宁愿不在本地机器上创建别名)

解决方案

如果您无法调整远程端的有效PATH 1 ,那么您必须从本地端指定程序的位置。



当您发现时, git clone 可以为 -u / path / to / git-upload-pack (或 - upload-pack / path / to / git-upload-pack )。



git fetch git pull 接受 - -upload-pack / path / to / git-upload-pack (不是 -u ,但是,因为这对于这些程序来说意味着别的东西)。他们还检查远程。< name> .uploadpack 配置变量。

git push 接受 - receive-pack / path / to / git-receive-pack 并检查远程。< name> .receivepack 配置变量。



克隆了存储库后,可以使用配置变量记录路径:

  git clone -u / home / bin / git-upload-pack user@server.com:mygitfolder 
cd mygitfolder
git config remote.origin.uploadpack / home / bin / git-upload-pack
git config remote.origin.receivepack / home / bin / git-receive-pack

然后,您可以在不必指定路径的情况下进行push,fetch或pull。




1
您说环境变量[被阻止用于SSH帐户]。如果您的意思是 sshd PermitUserEnvironment 设置已关闭(意味着您不能使用 environment =PATH = / home / bin:/ usr / bin:/ bin在你的 .ssh / authorized_keys 文件中),那么你仍然可以修改你的默认路径通过一个shell初始化文件(例如 .bashrc )。


So I'm using GIT, trying to push code to my remote server.

  • on a shared unix hosting, and I'm not allowed to have my own environment variables (blocked for SSH accounts) and no sudo access.
  • managed to install git successfully in my /home/
  • trying to push code to the server returns : bash: git-upload-pack: command not found
  • $PATH variable is set - because git is installed in my /home/
  • to get things working, I had to use to following clone command :

    git clone -u /home/bin/git-upload-pack user@server.com:mygitfolder

  • same versions of git on local machine/remote server (1.7.0.4)

so from what I can gather, I need to basically :

  • find a way to either wrap my environment variable every time I push to the server or
  • specify the path of my git-receive-pack while pushing to the server

I understand I could create a hook that would take effect as I push, but have not managed to find where/how this is implemented.

(I would rather not create an alias on my local machine)

解决方案

If you can not adjust the effective PATH on the remote side1, then you will have to specify the location of the programs from your local side.

As you found, git clone can be given -u /path/to/git-upload-pack (or --upload-pack /path/to/git-upload-pack).

git fetch and git pull accept --upload-pack /path/to/git-upload-pack (not -u, however, since it means something else to these programs). They also check the remote.<name>.uploadpack configuration variable.

git push accepts --receive-pack /path/to/git-receive-pack and checks the remote.<name>.receivepack configuration variable.

Once you have your repository cloned, you can use the configuration variables to record the paths:

git clone -u /home/bin/git-upload-pack user@server.com:mygitfolder
cd mygitfolder
git config remote.origin.uploadpack /home/bin/git-upload-pack
git config remote.origin.receivepack /home/bin/git-receive-pack

Then you can push, fetch, or pull without having to specify the path.


1 You said that "environment variables [are] blocked for SSH accounts". If you mean that the sshd has its PermitUserEnvironment setting turned off (meaning that you can not use environment="PATH=/home/bin:/usr/bin:/bin" in your .ssh/authorized_keys file), then you still might be able to modify your default PATH via a shell initialization file (e.g. .bashrc).

这篇关于GIT:&quot; git-upload-pack:command not found&quot;同时推送到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆