Setting up Git™ version control in cPanel helps you manage changes to your website’s files efficiently. This guide will walk you through the process step-by-step, even if you're new to version control.
- Accessing cPanel
First, log in to your cPanel account. You can simply do this by visiting yourdomain.com/cpanel in your web browser and entering your username and password. - Finding Git™ Version Control
Once you're in the cPanel dashboard, scroll down to the “Files” section and look for the “Git™ Version Control” icon. Click on it to open the Git™ Version Control interface. - Creating a Repository
To start using Git™, you need to create a repository. A repository is where your project files and their history are stored. Click the “Create” button.
Enter the following details:- Repository Path: This is where your repository will be stored on your server. For example, you might enter /home/yourusername/repositories/myproject.
- Repository Name: Give your repository a name. This can be anything descriptive of your project. Click “Create” to set up the repository.
- Cloning a Repository
If you already have a Git repository, you can clone it to your cPanel account. Cloning copies an existing repository to your server.
Click the “Create” button. Select the “Clone a Repository” tab. Enter the following details:- Clone URL: This is the URL of the existing repository you want to clone. It might look something like https://github.com/username/repository.git.
- Repository Path: This is where the cloned repository will be stored on your server. Click “Create” to clone the repository.
- Managing Your Repository
Once your repository is set up, you can manage it using Git commands. You’ll need to use SSH to access your server and run these commands. Here’s a quick overview:- Commit Changes: You have to commit any changes you make to your files to the repository. To commit, run the following command: git commit -m "Your commit message".
- Push Changes: To push your changes to a remote repository (such as GitHub), run git push origin main.
- Pull Changes: To update your local repository with changes from the remote repository, run git pull origin main.
- Executing Git commands over SSH
You have to set up an SSH connection to your server to run Git commands. Here's how to do it:- Use an SSH client such as Terminal (macOS/Linux) or PuTTY (Windows).
- Using your cPanel account, password, and server IP address, establish a connection to your
server. - For instance, you may write ssh yourusername@yourserverip in Terminal.
Once connected, navigate to your repository directory using cd /path/to/your/repository and start using Git commands.
By following these steps, you can set up and manage Git™ version control in cPanel, helping you keep your website’s files organized and track changes efficiently