How to Use Git Version Control to Upload Files on cPanel

You are here:
Estimated reading time: 1 min

Using Git Version Control in cPanel allows you to deploy and manage your code efficiently. Follow these steps to upload files via Git:


Step 1: Log in to cPanel

Go to domain.com/cpanel and enter your credentials.


Step 2: Open Git Version Control

  • Scroll down to the Files section and click on Git Version Control.
  • Click Create to add a new repository.

Step 3: Clone or Create a Repository

  • Option 1: Clone an Existing Repository
    • Select Clone Repository.
    • Enter the Git Repository URL (e.g., GitHub, GitLab, or Bitbucket).
    • Choose the directory where you want to clone the repo.
    • Click Create to complete the cloning process.
  • Option 2: Create a New Repository
    • Select Create New Repository.
    • Choose a directory for the repository.
    • Click Create to initialize a new repository.

Step 4: Upload and Push Files from Local to cPanel (If Not Cloned)

If you are working on your local computer, follow these steps:

  1. Initialize Git (if not done already)
    bash
    
    git init
    
  2. Add Remote Repository (If you created a repo in cPanel and need to push from local)
    bash
    
    git remote add origin ssh://your-cpanel-username@your-domain.com/home/your-cpanel-user/repo-directory  
    
  3. Add and Commit Changes
    bash
    
    git add .  
    git commit -m "Initial commit"  
    
  4. Push to cPanel Repository
    bash
    
    git push origin main  
    

    If your branch is master, use:

    bash
    
    git push origin master  
    

Step 5: Deploy the Code in cPanel

  • Go to cPanel > Git Version Control.
  • Click on your repository.
  • Click Manage > Pull or Deploy to fetch the latest updates from your Git repo.

Automating Deployment (Optional)

  • Inside the Manage section of the repository in cPanel, you can set up an Automatic Deployment Script.
  • This will automatically pull the latest updates when you push changes from your local machine.

Now, your files are uploaded and deployed using Git!

Was this article helpful?
Dislike 0

Author

Joshua

Web Hosting Geek Technical Support Staff G Online Sites