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
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.
public_html/
from your cPanel VPS to your Ubuntu machine.Probably
scp -r [email protected]:/home/user/public_html/
git init /path/to/public_html/
public_html
using Git as normal.Nothing special here. Edit, add, and commit as normal.
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.
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 postpost-receive
hook to run them.You can find more about it in cPanel’s official documentation