{"id":12220,"date":"2025-06-12T13:43:10","date_gmt":"2025-06-12T07:58:10","guid":{"rendered":"https:\/\/nestnepal.com\/blog\/?p=12220"},"modified":"2025-06-12T13:46:34","modified_gmt":"2025-06-12T08:01:34","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>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\/\" target=\"_blank\" rel=\"noopener\">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 decoding=\"async\" width=\"406\" height=\"235\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-version.jpeg\" alt=\"git-version\" class=\"wp-image-12221 lazyload\" style=\"--smush-placeholder-width: 406px; --smush-placeholder-aspect-ratio: 406\/235;width:455px;height:auto\" data-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\" data-sizes=\"(max-width: 406px) 100vw, 406px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p>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>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 class=\"wp-block-heading\"><strong>Why Use Git with cPanel?<\/strong><\/h2>\n\n\n\n<p>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 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<p>To follow this guide, you\u2019ll need:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"736\" height=\"552\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/Control-Panel.jpeg\" alt=\"cPanel\n\" class=\"wp-image-12223 lazyload\" style=\"--smush-placeholder-width: 736px; --smush-placeholder-aspect-ratio: 736\/552;width:452px;height:auto\" data-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\" data-sizes=\"(max-width: 736px) 100vw, 736px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/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 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>\u2705 Your Git repo is now live inside your hosting account.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 2: Set Up SSH Access (For Secure Pushes)<\/strong><\/h2>\n\n\n\n<p>Using Git securely requires <strong>SSH authentication<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>On Your Local Computer:<\/strong><\/h3>\n\n\n\n<p>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>cat ~\/.ssh\/id_rsa.pub<\/p>\n\n\n\n<h3 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>Done! You can now push to your repo securely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 3: Add Remote &amp; Push Code from Local Git<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>From your terminal:<\/strong><\/h3>\n\n\n\n<p>cd your-local-project-folder<\/p>\n\n\n\n<p>git init<\/p>\n\n\n\n<p>git remote add live ssh:\/\/youruser@yourdomain.com\/home\/youruser\/repositories\/my-website<\/p>\n\n\n\n<p>git add.<\/p>\n\n\n\n<p>git commit -m &#8220;Initial commit&#8221;<\/p>\n\n\n\n<p>git push live master<\/p>\n\n\n\n<p>Now your code lives on your server.<\/p>\n\n\n\n<p>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 class=\"wp-block-heading\"><strong>Step 4: Deploy the Code to Public_HTML (Live Website)<\/strong><\/h2>\n\n\n\n<p>Just because the repo lives on your server doesn\u2019t mean it\u2019s live yet.<\/p>\n\n\n\n<p>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>Boom! Git now powers your website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Optional: Auto-Deploy on Push (Post-Receive Hook)<\/strong><\/h2>\n\n\n\n<p>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>#!\/bin\/bash<\/p>\n\n\n\n<p>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>chmod +x post-receive<\/p>\n\n\n\n<p>Now every push = auto update.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Git Workflow Example: Laravel App Deployment<\/strong><\/h2>\n\n\n\n<p>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 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>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 decoding=\"async\" width=\"612\" height=\"344\" data-src=\"https:\/\/nestnepal.com\/blog\/wp-content\/uploads\/2025\/06\/git-control.jpg\" alt=\"git-support\" class=\"wp-image-12222 lazyload\" data-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\" data-sizes=\"(max-width: 612px) 100vw, 612px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 612px; --smush-placeholder-aspect-ratio: 612\/344;\" \/><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 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 class=\"wp-block-heading\"><strong>Recap: Git-Powered Hosting = Smarter Web Development<\/strong><\/h2>\n\n\n\n<p>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>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>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","protected":false},"excerpt":{"rendered":"<p>Gone are the days of dragging and dropping files over FTP and manually updating production websites. Today, smart developers and&#8230;<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[205,7],"tags":[117,447],"class_list":["post-12220","post","type-post","status-publish","format-standard","hentry","category-control-panel","category-web-hosting","tag-cpanel","tag-git-version"],"_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":2,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/12220\/revisions"}],"predecessor-version":[{"id":12226,"href":"https:\/\/nestnepal.com\/blog\/wp-json\/wp\/v2\/posts\/12220\/revisions\/12226"}],"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}]}}