# Use Git over SSH
Source: https://docs.webgee.com/en/development/using-git-via-ssh



Use Git on your hosting account over SSH. Applies to shared and reseller hosting
with SSH enabled.

Git is installed, but it is &#x2A;*not on your `PATH`**, so `git` alone returns
`command not found`. That is the whole difficulty.

## The full path [#the-full-path]

```bash
/usr/local/cpanel/3rdparty/bin/git
```

For example:

```bash
/usr/local/cpanel/3rdparty/bin/git clone https://github.com/example/repo.git
/usr/local/cpanel/3rdparty/bin/git status
```

## Make it permanent [#make-it-permanent]

Typing that every time is unbearable. Add an alias to `~/.bashrc`:

```bash
echo 'alias git="/usr/local/cpanel/3rdparty/bin/git"' >> ~/.bashrc
source ~/.bashrc
```

Or put the directory on your `PATH`, which also fixes tooling that shells out to
`git` itself:

```bash
echo 'export PATH="/usr/local/cpanel/3rdparty/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```

Prefer the second if you use anything that invokes Git indirectly — Composer,
for instance.

## Deploying from a repository [#deploying-from-a-repository]

A common pattern is cloning into your document root and pulling to deploy:

```bash
cd ~/public_html
/usr/local/cpanel/3rdparty/bin/git clone https://github.com/example/site.git .
```

<Callout type="error">
  Cloning into `public_html&#x60; 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`:

  ```apache
  RedirectMatch 404 /\.git
  ```

  or clone outside the web root and deploy from there, which is safer.
</Callout>

## Authenticating to a private repository [#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](/en/development/connect-via-ssh) for key generation.

<Callout type="warn">
  Never put a token in a remote URL that gets committed. `git remote -v` shows
  it, and it ends up in your shell history.
</Callout>

## cPanel's Git Version Control [#cpanels-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 [#related]

* [Connect over SSH](/en/development/connect-via-ssh)
* [Move a local WordPress site to your hosting](/en/hosting/wordpress/deploy-local-wordpress-setup-into-your-cpanel-account)
