{"id":633,"date":"2021-07-23T12:34:27","date_gmt":"2021-07-23T12:34:27","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/guide-to-git-how-to-set-up-deployment\/"},"modified":"2021-07-23T12:34:27","modified_gmt":"2021-07-23T12:34:27","slug":"guide-to-git-how-to-set-up-deployment","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/guide-to-git-how-to-set-up-deployment\/","title":{"rendered":"Guide to Git\u2122 &#8211; How to Set Up Deployment"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>) allows you to configure deployment for your cPanel-managed repositories. While many deployment configurations are possible, this document only outlines two types of deployment that you can configure.<\/p>\n<h3 id=\"push\">Push<\/h3>\n<p><strong>Push<\/strong> deployment first pulls changes from a remote repository to your local computer. Then, you can push them to your cPanel-managed repository. The system will automatically deploy changes that you push to the cPanel-managed repository.<\/p>\n<\/p>\n<p><center><br \/>\n<img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/git-push-deployment-workflow-1.png\" title=\"git-push-deployment-workflow-1\"><br \/>\n<em>Push deployment.<\/em><br \/>\n<\/center><\/p>\n<h3 id=\"pull\">Pull<\/h3>\n<p><strong>Pull<\/strong> deployment pulls changes from a remote repository to your local computer and pushes new changes from your local computer to the remote repository. You can then use the <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>) to manually deploy changes that you pull from the remote repository.<\/p>\n<\/p>\n<p><center><\/p>\n<figure>\n    <img src=\"https:\/\/ssdsunucum.com\/blog\/wp-content\/uploads\/2021\/07\/git-pull-deployment-workflow-1.png\" title=\"git-pull-deployment-workflow-1\"><br \/>\n<\/figure>\n<p><em>Pull deployment.<\/em>\n<\/p>\n<p><\/center><\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>If you experience issues when you configure Git deployment, read the following documents:<\/p>\n<ul>\n<li>\n<p>Guide to Git &#8211; Set Up Access to Private Repositories<\/p>\n<\/li>\n<li>\n<p>Git Version Control Series: Git Problems and How to Fix Them<\/p>\n<\/li>\n<\/ul><\/div>\n<\/div>\n<h2 id=\"set-up-push-deployment\">Set up push deployment<\/h2>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>We recommend that you use this type of deployment.<\/p>\n<\/p><\/div>\n<\/div>\n<h3 id=\"create-an-empty-repository-on-your-cpanel-account\">Create an empty repository on your cPanel account.<\/h3>\n<p>If the repository that you wish to deploy does not already exist on your cPanel account, use cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>) to create one.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>For this type of deployment, do <strong>not<\/strong> clone a remote repository during this step. Instead, create an empty repository.<\/p>\n<\/p><\/div>\n<\/div>\n<h3 id=\"clone-the-remote-repository-to-your-local-computer\">Clone the remote repository to your local computer.<\/h3>\n<p>If you have not already cloned it, clone the remote repository. For example, run the following command to clone a repository, where <code>URL<\/code> represents the remote repository\u2019s clone URL:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">git clone URL<\/code><\/pre>\n<\/div>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n<p>To clone private repositories, you must perform additional steps. If you do not perform these steps, you will experience errors when you attempt to use Git. For more information, read our Guide to Git &#8211; Set Up Access to Private Repositories documentation.<\/p>\n<\/p><\/div>\n<\/div>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>You can find the repository\u2019s clone URL by performing the following steps:<\/p>\n<ol>\n<li>\n<p>Navigate to cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>)<\/p>\n<\/li>\n<li>\n<p>Locate the desired repository in the list of repositories and click <em>Manage<\/em>.<\/p>\n<\/li>\n<li>\n<p>The URL appears under the <em>Clone URL<\/em> heading.<\/p>\n<\/li>\n<\/ol><\/div>\n<\/div>\n<h3 id=\"create-the-cpanel-yml-file\">Create the .cpanel.yml file.<\/h3>\n<p>In order to deploy changes from a cPanel-managed repository, you <strong>must<\/strong> check a <code>.cpanel.yml<\/code> file in to the top-level directory of your repository. You can create and commit this file to your local computer\u2019s copy of the repository, or you can create and commit it on the remote repository.<\/p>\n<ul>\n<li>\n<p>If you use the remote repository, you will require read-write access or can submit a pull request to the remote repository.<\/p>\n<\/li>\n<li>\n<p>This tutorial uses changes from the local computer rather than the remote repository.<\/p>\n<\/li>\n<\/ul>\n<p>For example, a <code>.cpanel.yml<\/code> file may resemble the following example:<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">5\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">6\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">---\ndeployment:\n tasks:\n - export DEPLOYPATH<span style=\"color:#f92672\">=<\/span>\/home\/user\/public_html\/\n - \/bin\/cp index.html $DEPLOYPATH\n - \/bin\/cp style.css $DEPLOYPATH<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-cpanel\">\n<div class=\"callout-heading\">More:<\/div>\n<div class=\"callout-content\">\n<p>For more information about the <code>.cpanel.yml<\/code> file, read our Guide to Git &#8211; Deployment documentation.<\/p>\n<\/p><\/div>\n<\/div>\n<h3 id=\"add-the-cpanel-managed-repository-as-a-remote\">Add the cPanel-managed repository as a remote.<\/h3>\n<p>From your local computer, run the following command to add the cPanel-managed repository as the local computer\u2019s remote:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">git remote add origin URL<\/code><\/pre>\n<\/div>\n<p>In this command, <code>URL<\/code> represents the cPanel-managed repository\u2019s clone URL.<\/p>\n<h3 id=\"push-changes-to-the-cpanel-managed-repository\">Push changes to the cPanel-managed repository.<\/h3>\n<p>From your local computer, run the following command to push the changes from your local computer to the cPanel-managed repository:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">git push -u origin HEAD<\/code><\/pre>\n<\/div>\n<p>After the cPanel-managed repository contains the <code>.cpanel.yml<\/code> file, the system will automatically deploy any changes that you push to it.<\/p>\n<div class=\"callout callout-warning\">\n<div class=\"callout-heading\">Important:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>If you experience errors when you attempt to push your changes, the repository may be private and require SSH access. For more information, read our Guide to Git &#8211; Set Up Access to Private Repositories documentation.<\/li>\n<\/ul>\n<h2 id=\"set-up-pull-deployment\">Set up pull deployment<\/h2>\n<h3 id=\"clone-the-remote-repository-to-your-cpanel-account\">Clone the remote repository to your cPanel account.<\/h3>\n<p>If the repository that you wish to deploy does not already exist on your cPanel account, use cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>) to clone the desired remote repository.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<p>This feature enforces several restrictions on clone URLs, and it verifies the remote host\u2019s public SSH keys for <code>ssh:\/\/<\/code> clone URLs.<\/p>\n<\/p><\/div>\n<\/div>\n<h3 id=\"clone-the-remote-repository-to-your-local-computer\">Clone the remote repository to your local computer.<\/h3>\n<p>If you have <strong>not<\/strong> already cloned the remote repository, use the terminal on your local computer to clone the remote repository.<\/p>\n<p>For example, run the following command to clone a repository, where URL represents the remote repository\u2019s clone URL:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">&lt;p&gt;git clone URL&lt;\/p&gt;<\/code><\/pre>\n<\/div>\n<h3 id=\"create-the-cpanel-yml-file\">Create the .cpanel.yml file.<\/h3>\n<p>In order to deploy changes from a cPanel-managed repository, you <strong>must<\/strong> check a <code>.cpanel.yml<\/code> file in to the top-level directory of your repository. You can create and commit this file to your local computer\u2019s copy of the repository, or you can create and commit it on the remote repository.<\/p>\n<p>If you use the remote repository, you will <strong>require<\/strong> read-write access or can submit a pull request to the remote repository.<br \/>\nThis tutorial uses changes from the local computer rather than the remote repository.<\/p>\n<div class=\"highlight\">\n<div style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\">\n<table style=\"border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;\">\n<tr>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\"><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">1\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">2\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">3\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">4\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">5\n<\/span><span style=\"margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f\">6\n<\/span><\/code><\/pre>\n<\/td>\n<td style=\"vertical-align:top;padding:0;margin:0;border:0;;width:100%\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">---\ndeployment:\n tasks:\n - export DEPLOYPATH<span style=\"color:#f92672\">=<\/span>\/home\/user\/public_html\/\n - \/bin\/cp index.html $DEPLOYPATH\n - \/bin\/cp style.css $DEPLOYPATH<\/code><\/pre>\n<\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/div>\n<div class=\"callout callout-cpanel\">\n<div class=\"callout-heading\">More:<\/div>\n<div class=\"callout-content\">\n<p>For more information about the <code>.cpanel.yml<\/code> file, read our Guide to Git &#8211; Deployment documentation.<\/p>\n<\/p><\/div>\n<\/div>\n<h3 id=\"push-changes-to-the-remote-repository\">Push changes to the remote repository.<\/h3>\n<p>From your local computer, run the following command to push the changes from your local computer to the remote repository:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-bash\" data-lang=\"bash\">&lt;p&gt;git push origin HEAD&lt;\/p&gt;<\/code><\/pre>\n<\/div>\n<h3 id=\"pull-and-deploy-changes-from-the-cpanel-interface\">Pull and deploy changes from the cPanel interface.<\/h3>\n<p>To pull the changes from the remote repository and then manually deploy them, perform the following steps:<\/p>\n<ol>\n<li>\n<p>Navigate to cPanel\u2019s <em>Git Version Control<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control<\/em>).<\/p>\n<\/li>\n<li>\n<p>Locate the desired repository in the list of repositories and click <em>Manage<\/em>.<\/p>\n<\/li>\n<li>\n<p>Click the <em>Pull or Deploy<\/em> tab.<\/p>\n<\/li>\n<li>\n<p>Click <em>Update from Remote<\/em> to pull changes from the remote repository.<\/p>\n<\/li>\n<li>\n<p>Click <em>Deploy HEAD Commit<\/em> to deploy your changes.<\/p>\n<\/li>\n<\/ol>\n<p>Repeat these steps each time that you wish to pull and deploy changes. The system will <strong>not<\/strong> deploy changes for this deployment type automatically.<\/p>\n<\/p><\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview cPanel\u2019s Git Version Control interface (cPanel &gt;&gt; Home &gt;&gt; Files &gt;&gt; Git Version Control) allows you to configure deployment for your cPanel-managed repositories. While many deployment configurations are possible, this document only outlines two types of deployment that you can configure. Push Push deployment first pulls changes from a remote repository to your local &hellip;<\/p>\n","protected":false},"author":1,"featured_media":634,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/633"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=633"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/633\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/634"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}