Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Setting up Git Version Control

Discussion in 'General Discussion' started by Stephen Price, Sep 28, 2018.

  1. Stephen Price

    Stephen Price Registered

    Joined:
    Sep 28, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    France
    cPanel Access Level:
    Root Administrator
    I want to set up Git Version Control but I have one question I can't seem to find an answer to.
    If a websites files are located in /public_html/versiontesting, can I just set Clone Repository to off and then set repository path to /home/zencart/public_html/versiontesting to make the actual site files the repository?

    I tried to do this, but when doing git clone on a local machine, Terminal reports "warning: You appear to have cloned an empty repository." If I click the File Manager button from within Git Version Control I see the directory tree of the website.

    If that is normal, how do I create the Master branch so that my local clone actually has some content?
     
  2. cPanelAdamF

    cPanelAdamF cPanel Product Owner Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    244
    Likes Received:
    59
    Trophy Points:
    103
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    You're missing one step and then you're good to go:

    We don't automatically create a commit for the files you've already got in the /public_html/versiontesting folder.

    If you'd like the files you already have in the /public_html/versiontesting folder to be tracked by the git repo you created there, you'll have to ssh in and do a "git add .; git commit" to get them checked in. Once that's done, you can return to your fork on your laptop there and do a "git pull" to bring down those files.

    The other thing to consider is that we don't typically suggest that your git repo itself exist inside the document root of your domain. You can totally do it if you want to, but, in general, it's better to have it live somewhere else and then use our Automated Deployment mechanism to get the files where they need to go. That way you don't risk the public unnecessarily having access to your codebase. (We do have protections in place for this, but it's best to manage your risk wherever you can!)
     
    Stephen Price and cPanelMichael like this.
  3. Stephen Price

    Stephen Price Registered

    Joined:
    Sep 28, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    France
    cPanel Access Level:
    Root Administrator
    Thank you for the reply.
    If I follow your advice and use a remote repository, does that also get updated when I do a push? If there are multiple people working on a job then the main repo needs to be updated, not just the files located in the document root of the domain.
     
  4. cPanelAdamF

    cPanelAdamF cPanel Product Owner Staff Member

    Joined:
    Mar 21, 2013
    Messages:
    244
    Likes Received:
    59
    Trophy Points:
    103
    Location:
    Houston TX
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Yes, though it's important that you keep this model in mind for it to work best:
    • /home/zencart/repositories/yourproject - This is the location of your git repository (NOTE: Not inside the public_html folder)
    • Inside your project, ask your developers to create a .cpanel.yml file which performs the deployment tasks necessary to deploy your website. Give them Guide to Git - Deployment - cPanel Knowledge Base - cPanel Documentation because it fully explains the whole deployment process.
    • Your team will need to know that your website is hosted in /home/zencart/public_html/versiontesting. The deployment tasks will need to write into /home/zencart/public_html/versiontesting.
    You've described that more than one person will work on the project. They'll need the 'Clone URL' from the Git Version Control feature for your repository and you'll need to authorize their SSH Keys to give them access to pull and push to it. (Use SSH Access - Version 76 Documentation - cPanel Documentation to set that up for them.)

    Once that's set up, you and your team will need to agree to use one specific git branch only for deployment. Then, you should set that branch as the "active branch" in your cPanel account. When they're ready to publish their work, they should "merge" their work into that branch and then do a git push to push those changes up to your account. When the changes arrive, cPanel will recognize that new work has arrived on the "active branch" and perform the deployment tasks they put in your .cpanel.yml
     
    Stephen Price likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice