GIT:“git-upload-pack:找不到命令”推送到远程服务器时

发布于 2024-11-08 01:57:21 字数 713 浏览 1 评论 0原文

所以我正在使用 GIT,尝试将代码推送到我的远程服务器。

  • 在共享的 UNIX 主机上,我不允许拥有自己的环境变量(SSH 帐户被阻止)并且没有 sudo 访问权限。
  • 设法在我的 /home/ 中成功安装 git
  • 尝试将代码推送到服务器返回: bash: git-upload-pack: command not found
  • $PATH 变量已设置 - 因为 git 安装在我的 /home/
  • to get一切正常,我必须使用以下克隆命令:

    git clone -u /home/bin/git-upload-pack [电子邮件受保护]:mygitfolder

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

因此从我收集到的信息来看,我基本上需要:

  • 找到一种方法在每次推送到服务器时包装我的环境变量 或者
  • 在推送到服务器时指定我的 git-receive-pack 的路径

我知道我可以创建一个在推送时生效的钩子,但还没有找到它的实现位置/方式。

(我不想在本地计算机上创建别名)

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 [email protected]: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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

筑梦 2024-11-15 01:57:21

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

正如您所发现的, git clone 可以给出 -u /path/to/git-upload-pack (或 --upload-pack /path/to/git-upload-pack)。

git fetchgit pull 接受 --upload-pack /path/to/git-upload-pack (但是,不是 -u,因为它对这些程序意味着其他东西)。他们还检查 remote..uploadpack 配置变量。

git 推送接受 --receive-pack /path/to/git-receive-pack 并检查 remote..receivepack 配置变量。

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

git clone -u /home/bin/git-upload-pack [email protected]:mygitfolder
cd mygitfolder
git config remote.origin.uploadpack /home/bin/git-upload-pack
git config remote.origin.receivepack /home/bin/git-receive-pack

然后您可以推送、获取或拉取,而无需指定路径。


1
您说“环境变量被 SSH 帐户阻止”。如果您的意思是 sshd 已关闭其 PermitUserEnvironment 设置(意味着您无法使用 environment="PATH=/home/bin:/usr/bin :/bin" 在您的 .ssh/authorized_keys 文件中),那么您仍然可以通过 shell 初始化文件(例如 .bashrc >)。

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 [email protected]: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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文