Learn About Git, How To Set It Up, & Use It Via The Shared Web Hosting Control Panel

Quick Intro

Git allows you to track the process of a project's code development. Git is an open-source platform, and we are giving you an option to use local Git on our platform that you can control via your Web Hosting Control Panel.

You are getting a full Git functionality with native Git commands. It's a very handy tool if you already got used to a Git development process.

Important To Know Before You Begin

This is a LOCAL Git repository, meaning that you can use Web Host Most as your Git repository, and still use any Git client to work with your project.

The process of creating and connecting to the Git repository is not complicated, but requires your attention and patience.

Note: Please, make sure you have a Git Client installed and running. One of the Git Client examples is GitLab.

Note: This manual works for UNIX-based Operating Systems, such as Linux or Mac. Windows is not harder, it's just a bit different process that you can find with a ton of manuals around the internet.

Creating Git Repository

First, let's start with creating a Git repository via your Web Hosting Control Panel.

From your Web Control Panel, navigate to Development Tools > Git > Create Repository > Enter the name of the repository > Click Create Repository.

Creating A Local SSH Key (on your personal computer)

Creating a Git repository is not enough, You also need to generate an SSH Key using the device you are connecting from. In your case is the computer you are using.

The commands below could be used with UNIX-based systems only. Please, use guides around the internet if you need to connect using Windows machine.

Open your local machine's Terminal. From there, enter the command: sudo ssh-keygen -t rsa -b 4096 (this command generates the id_rsa.pub file inside of the .ssh/ folder).

Once the SSH Key has been generated, navigate to the default SSH directory of any UNIX-based system, which is ~/.ssh/ by default. Enter the command: sudo cd ~/.ssh/

When you are inside of the .ssh/ folder, create a config file. You can do this by typing: touch config (without any extensions)
Now, let's open the config file and add the necessary information of our server. To open and edit the file, use nano. Type: nano config

Inside of the config file, add the following credentials:
Host server1.webhostmost.com
Port 2323
Save the file (Ctrl + O), and exit (Ctrl + X).

Now, let's open the id_rsa.pub file. It's the key file that we have generated using commands above. Open the file with content with cat. Type: cat ~/.ssh/id_rsa.pub

Copy the entire file's content.

Connecting Your Local Machine To The Git Repository Via Web Control Panel

Now, when you have the key content copied, you need to paste it inside of the Web Panel.

From your Web Control Panel, navigate to Security Management > SSH Keys > Paste Key > Paste the key you've copied > Click Create See the Key in Authorized Keys tab.

Done! The Git repository is connected with your local machine now. However, there are few more steps left to connect it to your Git Client.

Initiating Git Folder On Your Local Machine

To start using Git, you have to set up the source folder of your project from where you are going to push updates to the server.

Using Terminal, navigate to the folder of your project that suppose to be added to the Git repository.

From the folder of your project, you need to initiate the Git. Using Terminal, type: sudo git init

Once you have initiated the project folder, make sure it has files. If it's empty, you can create any file for test, such as test.txt. If there are files already, don't create any extra files.

Now, let's add your project's folder to the GIt repository. Type: git add .  (make sure the dot sign is added, it means selecting ALL the files).

Now, we can commit to our repository by typing: git commit -m "My First Comment"

We need to create the branch. In this example, let's call it main, which you can use to commit to. Type: git branch -M main

Time to connect your local project to the existing Git repository by typing: git remote add origin URL (URL in our case is the link to the existing Git repository from the Web Control Panel > Development Tools > Git > Git URL).

Lets upload files to the server now. Type the command: git push -u origin main (it won't show up in your File Manager yet).

And, the last step is to setup Deploy Directory and the branch on the Web Control Panel side. To do so, navigate from your Web Control Panel > Development Tools > Git > Click the Plus Icon near the Git URL > Click Edit > Choose the branch name "main" in our case > Set the path to the root folder of your project. To deploy to the domain root directory, set the path to: domains/yourdomain.com/public_html > Click Save.

All set! You can use your Git Client as you wish, push updates and manage your project efficiently.

Was this answer helpful? 1 Users Found This Useful (1 Votes)