Use Git over SSH
Git is installed on WebGee servers but is not on your PATH. The full path to use, and how to make it permanent.
Use Git on your hosting account over SSH. Applies to shared and reseller hosting with SSH enabled.
Git is installed, but it is not on your PATH, so git alone returns
command not found. That is the whole difficulty.
The full path
/usr/local/cpanel/3rdparty/bin/gitFor example:
/usr/local/cpanel/3rdparty/bin/git clone https://github.com/example/repo.git
/usr/local/cpanel/3rdparty/bin/git statusMake it permanent
Typing that every time is unbearable. Add an alias to ~/.bashrc:
echo 'alias git="/usr/local/cpanel/3rdparty/bin/git"' >> ~/.bashrc
source ~/.bashrcOr put the directory on your PATH, which also fixes tooling that shells out to
git itself:
echo 'export PATH="/usr/local/cpanel/3rdparty/bin:$PATH"' >> ~/.bashrc
source ~/.bashrcPrefer the second if you use anything that invokes Git indirectly — Composer, for instance.
Deploying from a repository
A common pattern is cloning into your document root and pulling to deploy:
cd ~/public_html
/usr/local/cpanel/3rdparty/bin/git clone https://github.com/example/site.git .Cloning into public_html puts .git inside your web root, and on many
configurations it is downloadable. That exposes your entire history —
including any credentials ever committed, even if later removed.
Either block it in .htaccess:
RedirectMatch 404 /\.gitor clone outside the web root and deploy from there, which is safer.
Authenticating to a private repository
Use a deploy key or a personal access token, not your account password.
For a deploy key, generate one on the server and add the public half to the repository as read-only — see Connect over SSH for key generation.
Never put a token in a remote URL that gets committed. git remote -v shows
it, and it ends up in your shell history.
cPanel's Git Version Control
cPanel also has a Git Version Control interface under Files, which handles clone and pull without SSH. Easier for simple deployments; the command line is better for anything involving branches.
Related
Deploy a Node.js app from the Websites hub
Deploy a Node.js application to a domain from a Git repository, a ZIP file or an AI agent, and set its Node version, build output and environment variables.
Set the PHP timezone
Set date.timezone so PHP dates match your local time, and what to do when the Selector value appears not to apply.