简体   繁体   中英

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?

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".

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".

I actually do not understand how to do this (i am not much of cmd user).

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?

Thanks

You have to have git in the remote users path. 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.

This answer all applies to commands run on the remote server, eg over 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".

Either run git with the full path, eg

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

instead of git fetch , or add that directory to your path, eg

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.

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:

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

Then log off and log back on, and see if git works.

If there is no .bash_profile file, the above command will automatically create it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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