简体   繁体   English

Git在服务器上不起作用,而托管提供商说可以

[英]Git does not work on server, while hosting provider say it does

I want to use this workflow (i also use it with my other projects successfully): How to push to both GitHub and live server from local repository? 我想使用此工作流(我也成功地将其与其他项目一起使用): 如何从本地存储库同时推送到GitHub和实时服务器?

Now I have a new project on different hosting provider, and they say they do have GIT, however whenever I connect with my bach using ssh to the server, I cannot use git - "git: command not found". 现在,我在不同的托管服务提供商上有一个新项目,他们说他们确实有GIT,但是,每当我使用ssh与bach连接到服务器时,就无法使用git-“ git:找不到命令”。

Hosting support got me this answer: "To use it it is needed to specify the path to git, that is /usr/local/cpanel/3rdparty/bin/git". 托管支持使我得到了这个答案:“要使用它,需要指定git的路径,即/ usr / local / cpanel / 3rdparty / bin / git”。

I actually do not understand how to do this (i am not much of cmd user). 我实际上不明白该怎么做(我不是cmd用户)。

Or is there an alternative way of creating bare git in root and use post-hook to push push it to public location on the server? 还是有另一种方法可以在root用户中创建裸git并使用后钩将其推送到服务器上的公共位置?

Thanks 谢谢

You have to have git in the remote users path. 您必须在远程用户路径中具有git。 As your provider suggests that you have to specify the full path this is not yet the case. 由于您的提供者建议您必须指定完整路径,因此情况并非如此。 Modify the shell configuration of your login shell to include git in the PATH variable. 修改登录外壳程序的外壳程序配置,以将git包含在PATH变量中。

This answer all applies to commands run on the remote server, eg over SSH. 此答案全部适用于在远程服务器上运行的命令,例如通过SSH。

Hosting support got me this answer: "To use it it is needed to specify the path to git, that is /usr/local/cpanel/3rdparty/bin/git". 托管支持使我得到了这个答案:“要使用它,需要指定git的路径,即/ usr / local / cpanel / 3rdparty / bin / git”。

Either run git with the full path, eg 使用完整路径运行git ,例如

/usr/local/cpanel/3rdparty/bin/git fetch

instead of git fetch , or add that directory to your path, eg 而不是git fetch ,或将该目录添加到您的路径,例如

export PATH=$PATH:/usr/local/cpanel/3rdparty/bin
git fetch

If you go with this second option, you will probably want to add the export command to your shell configuration so you don't have to type it each time. 如果使用第二个选项,则可能需要将export命令添加到Shell配置中,这样就不必每次都键入它。

The details of how to do that vary by shell. 具体操作方法因外壳而异。 Assuming you are using Bash on the remote machine, try adding that line to the .bash_profile file in your home directory: 假设您正在远程计算机上使用Bash,请尝试将该行添加到主目录中的.bash_profile文件中:

echo export PATH=$PATH:/usr/local/cpanel/3rdparty/bin >> ~/.bash_profile

Then log off and log back on, and see if git works. 然后注销并重新登录,然后查看git有效。

If there is no .bash_profile file, the above command will automatically create it. 如果没有.bash_profile文件,上述命令将自动创建它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM