skip to Main Content

I have a cPanel VPS server, and on that server I have an account with jailed SSH. There is a website hosted on this account, with over 100 files/folders. I want to be able to use Git on my Ubuntu 16.04 LTS machine when I edit the website.

I need to setup Git on the cPanel server in the public_html folder and be able to pull the files to my local Ubuntu machine. When I edit files I want to use version control to track my changes.

I tried setting it up this way:

Create the git repo in the public_html folder on my cPanel server:

git init

Create an empty git repo on my local machine (Desktop) and run:

git init
git add remote origin [email protected]:/home/user/public_html
git fetch origin master

I’m probably doing this wrong, because I get this error: stdin: is not a tty

What am I missing here?

2

Answers


  1. As I understand it, you want to develop the site on your local Ubuntu machine and deploy it to a cPanel VPS. If so, you have it backwards. Git is not a deployment tool. Instead, develop and test the site locally, then copy it to the remote production server using some other tool.

    1. Copy public_html/ from your cPanel VPS to your Ubuntu machine.

    Probably scp -r [email protected]:/home/user/public_html/

    1. Init the repository on the local Ubuntu machine.

    git init /path/to/public_html/

    1. Develop in public_html using Git as normal.

    Nothing special here. Edit, add, and commit as normal.

    1. Copy the changes to the production server.

    When you’re ready to release, copy the files to the cPanel VPS. Use a tool such as rsync to efficiently sync the remote directory. Be sure to exclude the .git directory.

    You can do this with Git, but I recommend not going down that road. Git is not a deployment tool and forcing it into that role will lead to increasingly convoluted procedures.

    Login or Signup to reply.
  2. This is an old question and the option was not available at the time but I found the question while looking around the same subject and there is some new information.

    cPanel has since added support for git out of the box and includes features to support automatic deployment. Basically you create .cpanel.yml at the root of your project with commands to copy the files and cPanel installs a post post-receive hook to run them.

    You can find more about it in cPanel’s official documentation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search